UML's Sequence Diagram
An UML artifact sequence diagram is used for design, analysis and documentation purposes. A sequence diagram represents interactions between objects in a sequential order of occurrence. While developers use the diagram for documentation and analysis, business users use the diagram to communicate current business logic and intended changes in logic. Also the diagram can be used to specify current and future requirements.
Reverse Engineering a Sequence Diagram from source code.
Apart from UML benefits, effectively reverse engineering a sequence diagrams from source code helps in retro-documentation, retro-conceptualization, understanding current business logic and proposing changes in the current business logic.
Flowchart4j - comes as an Eclipse Plugin, and provides automatic control flow diagrams(flowcharts) and sequence diagrams for Java. Flowchart4j exports these diagrams to Microsoft Visio.
Generating a diagram
- Open a Java resource from your Java Project in Eclipse JDT editor.
- Select a method in the editor by clicking anywhere inside the method's code.
- Click the "Generate Sequence / Generate Flowchart" tool bar button.
Sequence Diagram View
Sequence Diagram View - Toolbar
Understanding the Sequence Diagram
The generated sequence diagram has "Object life lines" to represent the life time of an instance of a class, and "Message Calls" representing the interaction between them. The following diagram illustrates a sequence diagram generated for a given Java code.
- Object life lines are represented by "Yellow Blocks". with the name of the class as label.
- Message calls are represented by "Green" connectors, with the name of the method as label.
- Return messages are represented by "Blue" Connectors", with the return type as label.
- "Green Blocks" indicate that the object has been instantiated.
- "White Blocks" with a "+" sign indicate that there are second level calls, and can be expanded by "double clicking" the block.
- "White Blocks" with a "-" sign indicate that the block has been expanded already.
- "White" circles represent that there are no second level calls for the message.
- The first object life line "<Invoke>" is added for readability and does not represent any class.
- Messages / Connectors whose starting and ending are the same indicate that it is "Self" message, i.e. the current method calls another method of the same class.
Usability Features in Sequence Diagram View
- Inner level message calls can be expanded in place by double clicking the "block" with the "+" sign or opened as a new diagram by "Right Clicking" and choosing the "Open Sequence" context menu option.
- Sequence Diagram to Code Navigation: Click on the message ending block, to locate the corresponding code in the editor.
Sequence Diagram and Control Flow Diagram
Flowchart4j provides an add on to the "Flowchart View(Control Flow Diagram)" to generate sequence diagram for a given block in the flowchart. For e.g, we can generate the sequence diagram for the true or false part following an "if" condition. To generate sequence diagram for a block in the flowchart just "Right Click" on the "block" and choose "Open Sequence" from the context menu option.
Export Sequence Diagram to Microsoft Visio
Flowchart4j 2.0 can export the current sequence diagram to Microsoft Visio as UML Model Diagram, making it editable.
Download the Sample Visio Diagram