The forms of the sequence diagrams indirectly reflect the choices of structure. The following two diagrams present a centralized and a decentralized control mode respectively.
Sequence diagrams may be completed by textual notes, expressed either as free text or pseudo-code. The moment of emission of a message, called transition, may be specified within the diagram close to the starting point of the arrow used to represent the message. This name is then used as a reference — to build temporal constraints, for example — as in the diagram below. When propagation of the message lasts a significant time compared to the system's dynamics, the emission and reception times are shown by a (name/name´) pair.
Examples of temporal constraints built from transition names
The addition of pseudo-code on the left side of the diagram enables the representation of loops and branches so that sequence diagrams may represent the general layout of an interaction beyond the sole consideration of a particular scenario.
The following diagram represents a
loop. Object while
sends a message to A
without stopping, as long as the condition B
is true.X
The
loop may also be represented using an iteration condition, positioned directly on the message. The iteration is symbolized by the character while
, placed in front of the condition between brackets.*
As with loops, conditional branches may be represented using pseudo-code, placed on the left of the diagram. The following diagram shows that object
sends a message to object A
or object B
according to a condition C
.X
As before, conditions placed in front of messages may replace pseudo-code. The various branches are then represented by several arrows originating at the same moment, and can be distinguished by conditions placed in front of the messages. For each branch, conditions must be mutually exclusive and all cases must be dealt with.
Conditional branches on the message destination side are represented by doubling the lifeline of the target object. The difference between branches is indicated by a condition placed after the message, close to the entry point on the lifeline of the target object.
Pseudo-code also enables the putting into agreement of an initial interaction, as described by the user during the use case study, and an interaction between domain objects as built by the analyst.
© 1997 Editions, Eyrolles, Paris, France . All rights reserved.