Examining a Function's Control Flow
A full spectrum of displays in Imagix 4D supports software visualization and analysis. The highest, most abstract views, providing the best overall system-level understanding of the software, are the Subsystem Architecture diagrams. From there, a range of additional displays reduce scope and add detail, until the other extreme is reached with Flow Charts. The scope of each flow chart is narrowed to a single function, while the internal program logic and control flow of that function is presented in maximum detail.
There are a number of tasks where this detail is important. A software developer creating a function can use a flow chart to review the structure of his code, making sure that what he wrote matches the structure he had in mind. Code review team members can use the flow charts to methodically walk through the logic of what has been implemented. For test and QA engineers, the flow charts provide a basis for creating and checking the coverage of white box test cases. And software engineers inheriting the code can use the flow charts to get up to speed on the logic and structure of complex functions, before starting to refactor or otherwise maintain the software.
Imagix 4D's flow charts offer a series of alternate layouts. Each is optimized to show a different aspect of the program logic and control structure of a function. And within each alternative, a number of options further control the detail displayed. For the purpose of comparison, the following descriptions each display the same function.
The default is the Logic layout. The control flow is from top to bottom. Beyond that, the layout is optimized for understanding and tracing the program logic, rather than emphasizing the details of the control statements making up the decision structure.
In the Logic layout, the generally diamond-shaped symbols represent decisions, while blocks of in-line code are contained in rectangles. The paths resulting from yes/no decisions are indicated (by green or red dots at the decision points). (+ full)
In contrast, control structure is explicitly represented in the Structure layout. The logic flow is once again top to bottom. However, decision branches are explicitly laid out in parallel, and the opening of each control statement has a corresponding closing point. Reviewing a Structure layout results in an understanding of not only the logic, but also of the if / for / while / switch control structure that underpins that logic.
The Structure layout uses the same decision and code shapes as the Logic layout. Here, the option has been set to show function calls rather than the full source code for blocks on in-line code. (+ full)
Viewing just the underlying control structure, without any reference to the specific decisions being made, is possible through the Compact layout. The overall layout mirrors that of the Structure layout, with opening and closing points for decision paths, etc. However, all information about the actual source code is omitted, so the entire focus is on just the structure itself.
The Compact mode never contains code snippets, and so the symbols for the decision and blocks of code are simpler diamonds and squares, respectively.
The final mode is Sequence layout. In this alternative, no decisions or blocks of code are drawn in parallel. The top to bottom drawing of the flow chart mirrors the sequence of lines of code in the source file. This alternative provides a useful map for understanding where specific lines of code lie within the control logic.
Sequence layout uses the same symbols as Compact, with lines from the source code optionally displayed to the right of each graph symbol. (+ full)