Sequence Diagram

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 - V 2.0.0 - Watch a Demo

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.

Flowchart4j V 2.0.0

Generating a diagram

  1. Open a Java resource from your Java Project in Eclipse JDT editor.
  2. Select a method in the editor by clicking anywhere inside the method's code.
  3. Click the "Generate Sequence / Generate Flowchart" tool bar button.
  4. FC4J ToolBar

Sequence Diagram View

Sequence Diagram

Sequence Diagram View - Toolbar 

Sequence 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.

Sequence Diagram

  1. Object life lines are represented by "Yellow Blocks". with the name of the class as label.
  2. Message calls are represented by "Green" connectors, with the name of the method as label.
  3. Return messages are represented by "Blue" Connectors", with the return type as label.
  4. "Green Blocks" indicate that the object has been instantiated.
  5. "White Blocks" with a "+" sign indicate that there are second level calls, and can be expanded by "double clicking" the block.
  6. "White Blocks" with a "-" sign indicate that the block has been expanded already.
  7. "White" circles represent that there are no second level calls for the message.
  8. The first object life line "<Invoke>" is added for readability and  does not represent any class.
  9. 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

  1. 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.
  2. 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.

Control Flow - Sequence Diagram
 

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.

Export Sequence to Visio

Download the Sample Visio Diagram