A sequence diagram represents an interaction between objects that focuses on the message broadcast chronology. The notation is derived from the Object Message Sequence Chart3 of the Siemens Pattern Group. An object is represented by a rectangle and a vertical bar called the object's lifeline.
3Wiley 1996, Pattern-Oriented Software Architecture : A System of Patterns. ISBN 0471958697.
Objects communicate by exchanging messages, represented by horizontal arrows drawn from the message sender to the message recipient. The message sending order is indicated by the position of the message on the vertical axis. The vertical axis may be labeled to express the temporal constraints precisely — in the case of the modeling of a real time system, for example.
In object-oriented modeling, sequence diagrams are used in two very different ways, according to the phase of the lifecycle and the desired detail level.
The first use corresponds to the documentation of use cases — it focuses on the description of the interaction, often in terms that are close to the user, without getting into the details of synchronization. In this case, the information carried by the arrows corresponds to events that occur within the application domain. At this stage of modeling, the arrows do not yet correspond to 'message broadcasts' in the sense of programming languages, and the difference between control flows and data flows is not generally established. The diagram below represents the beginning of a phone conversation:
Example of the use of a sequence diagram to represent events that occur within a domain.
The second use is more software-oriented, and allows the precise representation of interactions between objects. The concept of a message unites all the types of communication between objects, in particular, procedure calls, discrete events, signals between flows of execution and hardware interrupts.
Sequence diagrams distinguish two main categories of message broadcasts:
A synchronous broadcast is represented by an arrow drawn from the message sender to its recipient. An asynchronous broadcast is represented by a half arrow:
The arrow that symbolizes a message may be drawn diagonally to represent transmission delays that are non-negligible with respect to the overall dynamics of the application:
An object may also send itself a message. This situation is represented by an arrow that loops along the lifeline of the object:
This construct does not always correspond to a real message — it may indicate an entry point into a lower level activity that is performed within the object. Internal interactions (between objects contained within a composite object) that are represented by a reflexive message may also be described in a sequence diagram.
Use of a reflexive message as an entry point into an internal interaction.
Object creation is represented by having the creation message point to the rectangle that symbolizes the created object. Deletion is identified by a letter
at the end of the lifeline, either at the same height as the message that causes the deletion, or after the last message sent by an object committing suicide.X
Sequence diagrams also allow the representation of activations for objects. An activation corresponds to the time during which an object performs an action, either directly or through another object that it uses as a sub-contractor. Activations are represented by rectangular stripes positioned along lifelines. The beginning and the end of a stripe correspond respectively to the beginning and the end of an activation.
The following diagram illustrates the case of an object
that activates another object A
. The activity period of B
'covers' the activity period of A
. In the case of a procedure call, the flow of execution is passed by B
to A
. Object B
is then blocked until A
returns to it.B
In the case of a procedure call, and more generally in the case of synchronous broadcasts, there is an implicit return at the end of the execution of the operation: it is not necessary to represent it in diagrams. Object
resumes execution when the action triggered in object A
terminates.B
Conversely, in the case of asynchronous broadcasts, the return must be shown when it exists. The following example shows an object
, initially activated by an object B
, that returns a message to object A
before ceasing its execution. It is necessary to be aware that the end of an object's activation does not correspond to the end of its life. A given object may be activated several times during its existence.A
The particular case of a recursive message broadcast is represented by a replication of the rectangular stripe. The object appears as if it were active multiple times.
© 1997 Editions, Eyrolles, Paris, France . All rights reserved.