Sequence diagrams

A sequence diagram is a UML diagram that illustrates the chronological sequence of messages between objects in an interaction. A sequence diagram consists of a group of participants, such as objects or roles, that are represented by lifelines and the messages that they exchange over time during the interaction.

A sequence diagram contains lifelines that represent properties of any UML element that shows behavior, including actors, systems or subsystems, classes, and components.

As the following table illustrates, you can use sequence diagrams to model interactions during different development phases.

Phase Application
Analysis During the analysis phase, you can use sequence diagrams to model the interactions of the class instances to realize a use case. Typically, one sequence diagram illustrates the main flow of events in the use case and additional diagrams model important alternate flows. The instances can maintain the boundary class, entity class, or control class stereotypes of their classes to indicate that they are analysis classes. In the analysis phase, sequence diagrams can help to identify the classes that are needed in a system and what their objects need to do in interactions.
Design During the design phase, you can refine sequence diagrams to model how the system completes the interactions. For example, architectural patterns are incorporated where appropriate and actual class operations are assigned to messages. In the design phase, sequence diagrams explain how the system works to accomplish interactions.
Development of a system architecture During the development of a system architecture, you can use sequence diagrams to model the behavior of design patterns and mechanisms that the system uses.

A sequence diagram belongs to an interaction in a behavior classifier, by default a collaboration. One collaboration might have multiple interactions, but one interaction can contain only one sequence diagram. You cannot move a sequence diagram in a model. Because a sequence diagram is canonical and represents the model itself, you cannot delete a diagram element from a sequence diagram. You must delete the element from the entire model.

As the following figure illustrates, when you create a sequence diagram, the collaboration and the interaction appear in the Model Explorer view, and an interaction frame appears in the diagram editor.

A sequence diagram is open in the Model Explorer view and the associated interaction frame is displayed 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 occurrences 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, you can use interaction occurrences to reference another interaction from within an existing interaction.

Related tasks
Modeling interactions by using sequence diagrams
Creating lifelines in sequence diagrams
Creating messages in sequence diagrams
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.