Skip to content

Narrow screen resolution Wide screen resolution Auto adjust screen size Increase font size Decrease font size Default font size default color brick color green color
You are here:Home arrow Swat4j™ arrow Visualization
Software Visualization Print E-mail


 

 

 

 

 

 

 

 

"Software visualization is the use of computer graphics and animation to help illustrate and present computer programs, processes, and algorithms. Software visualization systems can be used to understand how algorithms work, and they can be used in program development as a way to help programmers understand their code better."


As a first step in the direction of software visualization tools, Swat4j provides automatic flowchart[control flow graph] for Java methods.

Flowchart is a diagram that shows the operations performed in an information processing system and the sequence in which they are performed. Flowcharts come handy in understanding the paths of execution of the code written, thus one can easily understand the logic behind the code.
 
A control flow graph (CFG) is a representation, using graph notation, of all paths that might be traversed through a program during its execution. Each node in the graph represents a basic block, i.e. a straight-line piece of code without any jumps or jump targets; jump targets start a block, and jumps end a block. Directed edges are used to represent jumps in the control flow.

Flowchart is a directed graph, with nodes and directed edges. The directed edges represent the flow of control from one part of code to other. Each node represents a code block or condition block. A code block represents a set of code, with no branching instructions (jump or iteration) inside that. A condition block represents a branching statements condition and the edges from this represent the branches possible from the branching statement. There are two special basic blocks: entry block through which control enters into the code of interest, and exit block through which all the control flow leaves the code.

Control flow graphs can be modified to act as flowcharts for any code. In a control flow-graph, blocks ends with control statements and it doesn't have any special blocks for control statements. But in flowchart each control statement's condition is given a separate block. We have to separate the conditional control statements from the basic block of the control flow graph and create a new control block with the condition of the control statement.   Basic blocks for flowcharts can be generated programmatically by traversing through the code, similar to generating control flow graphs with minor modifications,

  • First block is distinguished as initial node; control flow starts with that node,
  • And a node is reserved as an Exit node, all the control-flows leaves the code will end here.
  • Other basic blocks are generated, with the condition that each blocks ends with a control statement.
  • The statements will be added to a block, until a control statement is encountered.
  • If a control statement encountered, the block is closed and a new block is generated with that control statement
  • A directed edge is placed from the closed block to the control statement block,
  • The procedure continued with the following statements after the control statement.


In the downside, by this method, we can't generate the special blocks like, Input, Output, and Document blocks in this kind of flowcharts. But that are essential for a professional flowchart. It can be solved by processing of each block in the second phase.


Reference & furthere reading on Software Visualization
[ACM Symposium on Software Visualization] http://rw4.cs.uni-sb.de/~diehl/softvis/org/index.php

 
< Prev   Next >