Sequence Diagrams

A sequence diagram shows interactions between objects in temporal order. It displays the objects involved in a system, indicating how and in what order the objects function. When forward engineering a software system, there are three areas where sequence diagrams are often applied. They are used to show details of use case diagrams, to model how messages and tasks move between components in a system, and to visualize the logic behind a sophisticated function, operation or procedure.

This third use is also valuable when reverse engineering an existing software system, in order to display aspects of control flow for the software. Imagix 4D generates sequence diagrams to aid in understanding and analysis of existing source code, by extending control flow analysis of the interactions between functions and variables beyond what can be depicted in and understood from standard call trees.

From its database containing comprehensive control and data flow information about the software being studied, Imagix 4D creates sequence diagrams to provide greater insight into the order of function calls and variable usage than exists in standard call trees.

To this traditional sequence information, Imagix 4D adds a second critical component of advanced analysis -- indication of the conditionality controlling the object interactions. Many function calls or variable sets and reads only occur when specific conditions are met; Imagix 4D sequence diagrams show this. In order to (1) provide this additional analytical insight and (2) at the same time support visualization of a wider scope of software in limited screen space, Imagix 4D sequence diagrams differ from the standard UML sequence diagram format.

Sequence Information

Here are a set of functions and variables displayed in a standard call tree graph on the left, and an equivalent sequence diagram on the right.

The normal Function Calls with Variables view on the left and the Sequence Diagram with Variables view on the right show the same set of functions (blue rectangles) and variables (green tetrahedrons), along with the fundamental calls (red lines), sets (aqua lines) and reads relationships between them.

While both graphs indicate general control flow horizontally from left to right, the placement of symbols in the call tree layout is optimized simply for readability and understanding. In contrast, the placement in the sequence diagram on the right indicates the actual order that the function calls and variable sets are made. The symbols in the second column appear from top to bottom in the order that they are accessed by the function in the first column.

The other major difference between the basic layout of the two graphs is that the sequence diagram shows that the variable is set twice by the function, while this can not be determined from the call graph. This layout also provides an example of where the Imagix 4D sequence diagram varies from the UML format. To minimize space requirements, each symbol in the Imagix 4D diagram appears only once; multiple uses of a symbol are indicated by multiple lines connecting into the inbound connector at the upper left side of the symbol shapes.

In the sequence diagram on the right, the simple shapes representing functions and variables in the standard call trees are replaced by larger, more complex representations. The larger shapes retain the same color and general contour, but contain advanced information related to the sequence and conditionality of the symbol interactions. Here again, the format of the Imagix 4D diagram differs from a traditional UML diagram.

Imagix 4D's reverse engineered sequence diagrams relate the use of a symbol to a specific line of code. To display that linkage, a snippet of the source code is displayed within the shape representing the function. Double-clicking will open to that source code line in a file editor, enabling further examination.

Additionally, the Imagix 4D sequence diagrams do not display lines from returns (purple triangles) on the left side of a function shape back to the calling function. Because of how function calls operate, each return would simply go back to the point in a calling function where the call was made. Because each function might have multiple return points, and each function might be called from multiple other functions, omitting the return lines greatly reduces the complexity and space requirements of the diagram. For further simplication, there is an option to disable display of the return points within a function.

Conditionality Information

Here is a more complex sequence diagram, where the conditionality, as well as the sequence, of the function calls and variable usage is indicated.

Source code snippets in function blocks display decisions that control whether a function call or variable set / read is actually reached (blue text) as well as the actual statements where symbols are used (black text).

Once again, relevent source code snippets are presented inside the function boxes, in the order that they occur in the function itself. But here, the snippets include more than just the simple statements where functions are called or variables are accessed.

Program logic within each function in the software controls the circumstances under which a function call is made or a variable is set or read. Imagix 4D's Sequence Diagram displays the relevent program logic, or conditionality information, for all calls, sets and reads of other symbols visible in the diagram. This is done by including the source code snippets representing this logic, down through the decision depth to the invocation of each displayed call, set or read.

Indenting is used to communicate this decision hierarchy. As each interior decision level is reached, the source code snippet is indented an additional amount. So a quick glance at the indenting indicates whether a specific use of a symbol is conditional. A longer inspection reveals the specific sequence of conditions that must be met.

This ability to explore the conditionality of symbol usage, combined with a sequence diagram's traditional ability to examine the sequence of symbol interactions, combine to make a powerful tool for detailed analysis of complex control flow in real-world code.

Sequence and
Conditionality Analysis