A sequence diagram shows the sequence of messages passed between objects. Sequence diagrams can also show the control structures between objects. For example, lifelines in a sequence diagram for a banking scenario can represent a customer, bank teller, or bank manager. The communication between the customer, teller, and manager are represented by messages passed between them. The sequence diagram shows the objects and the messages between the objects.
As the following table illustrates, you can use sequence diagrams at different stages during the development process to describe interactions between objects in a system.
Phase | Description |
---|---|
Analysis | During the analysis phase, you can use sequence diagrams to illustrate the interactions of class instances to realize a use case. In the analysis phase, sequence diagrams can help identify the classes that a system needs and what class objects do in interactions. |
Design | You can refine sequence diagrams to show how a system completes interactions. In the design phase, sequence diagrams explain how the system works to accomplish interactions. |
Construction | During the construction of a system architecture, you can use sequence diagrams to show the behavior of design patterns and mechanisms that the system uses. |
As the following figure illustrates, when you create a sequence diagram, the collaboration and the interaction appear in the Project Explorer view, and an interaction frame appears in the diagram editor.
In the interaction frame, you position instances that participate in the interaction in any order from left to right, and then you position the messages between the participants in sequential order from top to bottom. Execution specifications appear on the lifelines and show the start and finish of the flow of control.
Before UML 2.0, sequence diagrams were standalone diagrams. If you wanted to reuse a portion of a diagram, or even an entire diagram, you had to use comments. In UML 2.0 and later, you can use interaction uses to reference another interaction from within an existing interaction. By clicking the interaction use, you can open the referenced interaction and its sequence diagram.
The following topics describe the elements in sequence diagrams: