The context of an interaction comprises the arguments, the local variables created during execution, and the links between the objects that participate in the interaction.
An interaction is implemented by a group of objects that collaborate by exchanging messages. These messages are represented along the links that connect the objects, using arrows pointed towards the recipient of the message. The diagram below represents an elevator cabin that asks the door to open itself.
Unlike a sequence diagram, time is not represented explicitly in a collaboration diagram, and as a result the various messages are numbered to indicate the sending order.
Collaboration diagrams show the interactions between objects and the structural relationships that facilitate these interactions simultaneously. The following diagram represents the context of a mechanism for canceling a deletion operation. Before triggering the deletion operation of object B
, object A
performs a local copy of B
, so that if the deletion operation were to be canceled, object B
could be retrieved just as it was before the beginning of the interaction.
Objects and links created or deleted during an interaction may respectively be subject to the constraints {new}
or {deleted}
. Objects created and deleted within the same interaction are subject to the constraint {transient}
.
The notation allows the condensed representation of a family of links that are instances of the same association. This approach is particularly interesting when the group of objects under consideration is treated in a uniform way — being the target of the same message, for example. The following example illustrates a teacher who asks all his students to stand up; the iteration is indicated by the character *
placed in front of the message.
The notation allows an actor to be displayed within a collaboration diagram, in order to represent the triggering of interactions by an element that is external to the system. Thanks to this representation, the interaction may be described in a more abstract way, without getting into the details of user interface objects. The first message of the interaction is sent by the actor, represented either by the graphical symbol of the actors of the use case model, or by an object with a stereotype that specifies its role as an actor. The following diagram illustrates an interaction fragment; it corresponds to a person calling an elevator.
Objects that own a flow of control are called active. An active object may activate a passive object for the duration of an operation by sending a message to it. Once the message has been processed, the control flow is given back to the active object. In a multitasking environment, many objects may be active simultaneously. An active object is represented by a rectangle with a thicker frame than the one used for a passive object.
A message is represented by an arrow placed next to a link and pointing towards the object that is the destination of the message. A link is used as the transmission infrastructure for the message. A message triggers an action within the target object.
The syntax for a message label satisfies the general form:
synchronization sequence ':' result ':=' name arguments
The message, its arguments and return values, its rank within the interaction, and many other pieces of information, such as the nesting level or the synchronization, are specified at broadcast time.
The synchronization point of a message is expressed as a sequence of message broadcasts, terminated by the character /
. All the messages referenced in this list must have been sent in order to validate the broadcasting of the current message.
The syntax of a synchronization point has the following form,
rank {',' synchronization} '/'
Where rank
is given by:
[integer | name of flow of execution]{'.' rank}
The integer represents the rank of the message broadcast within the containing nesting level. The name identifies a parallel flow of execution within a nesting level. Therefore, the broadcast of message 3.1.3
immediately follows the broadcast of 3.1.2
within the nesting level 3.1
, while the broadcast of 3.1.a
is performed at the same time as that of 3.1.b
.
In the following example, the message Message
is sent when broadcasts A.1
and B.3
have been satisfied:
The sequence specifies the nesting level of the message broadcast within the interaction. The sequence consists of a sequence of terms separated by points. Each sequence has the following syntax:
rank [recurrence]
The recurrence
represents iteration and conditional branching, and takes the form:
'*' '[' iteration clause ']' block
Or:
'[' condition clause ']' block
The iteration clause is optional; it is expressed in a free form:
The notation of iteration infers the sequential broadcast of messages contained within the block. Parallel broadcast (also called diffusion) is represented by the sequence of characters *||
.
The condition clause is used to validate or invalidate the sending of messages contained within the block. The condition clause is expressed in a free form:
Results consist of a list of values returned by the message. These values may be used as parameters for the other messages that are part of the interaction. This field does not exist in the absence of return values. The format of this field is also free:
The name of the message often corresponds to an operation defined in the class of the object that is the destination of the message.
The arguments are the list of message parameters. The arguments and the message name uniquely identify the action that must be triggered in the target object. The arguments may contain return values from messages that were sent earlier, as well as navigation expressions constructed from the source object.
The following table of expressions gives some examples of the message broadcast syntax:
Label | Meaning |
4 : Display (x, y) |
Simple message |
3.3.1 : Display (x, y) |
Nested message |
4.2 : age := Subtract (Today, BirthDate) |
Nested message with return value |
[Age >= 18 years] 6.2 : Vote () |
Conditional message |
4.a, b.6 / c.1 : Turn on (Lamp) |
Synchronization with other flows of execution |
1 * : Wash () |
Iteration |
3.a, 3.b / 4 *|| [i := 1..n] : Turn off () |
Parallel iteration |
Message arguments are represented within diagrams using either pseudo-code, or directly in the programming language's syntax. The notation also proposes a graphical representation for arguments, using arrows ended with small circles. The following diagram gives an example of the graphical representation of the arguments of a message.
© 1997 Editions, Eyrolles, Paris, France . All rights reserved.