Section 10.2. Interaction Participants


10.2. Interaction Participants

You show participants in an interaction using a rectangle called a lifeline. The term lifeline illustrates UML's bias toward representing interaction diagrams using the sequence diagram notation. When shown in sequence diagrams, participants have a dashed line dropping down from a rectangle that shows how long the object is actually in existence. When used in other interaction diagram notations, such as communication diagrams, a lifeline is simply a rectangle. You show the name of the participant in the rectangle using the following notation:

          object_name [ selector ] : class_name ref decomposition

where:


object_name

Specifies the name of the instance involved in the interaction.


selector

Is an optional part of the name that can identify which particular instance in a multivalued element is to be used (for example, which EventHandler in an array of EventHandlers).


class_name

Is the name of the type of this participant.


decomposition

Is an optional part of the name that can point to another interaction diagram that shows details of how this participant processes the messages it receives (see "Decomposition").

UML defines a reserved participant name, self, that indicates the participant is the classifier that owns this interaction diagram.

Figure 10-2 shows a trivial interaction diagram with two participants and a message between them.

Figure 10-2. A trivial sequence diagram with two participants


You can show the destruction of a participant during an interaction using a stop symbol. Typically this is preceded by a «destroy» message to the object, though that isn't strictly necessary. Place an X at the bottom of the lifeline where the object ceases to exist. Figure 10-3 shows destroying a helper class after it has finished its work.

Figure 10-3. The destruction of a participant


To help make your sequence diagram accurately capture the behavior you are trying to model, you can introduce local variables. Local variables can hold return values, loop information, or just data you need for later processing. You show the values of local attributes relevant to the interaction using the same attribute syntax used inside of classifiers (see Chapter 2). Place their name and values in the upper left of the diagram, or in a note attached to the diagram. Figure 10-4 shows a more detailed version of the HashMap interaction using local variables.

Figure 10-4. A more complete HashMap interaction using local variables


In addition to local variables, sequence diagrams can access data in the participants. See "Messages" for examples.




UML 2.0 in a Nutshell
UML 2.0 in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596007957
EAN: 2147483647
Year: 2005
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net