Interaction Diagrams
An interaction diagram reveals an interaction, which consists of a set of objects and their respective relationships. It also includes the messages that may be transmitted among them.
Interaction Diagrams can be classified in to two categories:
1) Sequence Diagrams
2) Collaboration Diagrams
Sequence Diagram
A sequence diagram emphasizes the time ordering of messages between objects.
Objects
- Object naming
- Name classes consistently with your class diagram (same classes)
- Include instance names when objects are referred to in messages or when several objects of the same type exist in the diagram
- The life-line represents the object's life during the interaction
Messages:
|
- A message is represented by an arrow between the life lines of two objects
- The time required by the receiver object to process the message is denoted by an activation-box
- A message is labeled at a minimum with the message name
- Arguments and control information (conditions, iterations) may be included.
Optionally indicated using a dashed arrow with a label indicating the return value
- Model a return value only when you need to refer to it elsewhere
Example: As a parameter passed in another message
- Prefer modeling return values as part of a method invocation
Example: ok = isValid()
Condition: |
syntax: ‘[‘expression ']' message-label
The message is sent only if the condition is true.
Example:
Iteration
syntax: * [‘[‘ expression ‘]’'] message-label
The message is sent many times to possibly multiple receiver objects.
Operator
|
Meaning
|
alt
|
Alternative multiple fragments: Only
the one whose condition is true will execute
|
opt
|
Optional: The fragment executes only
if the supplied condition is true. Equivalent to an alt only with one trace
|
par
|
Parallel: Each fragment is run in
parallel
|
loop
|
Loop: The fragment may execute
multiple times, and the guard indicates the basis of iteration
|
region
|
Critical region: The fragments can
have only one thread executing it at once
|
neg
|
Negative: The fragments shows an
invalid interaction
|
ref
|
Reference: Refers to an interaction defined
on another diagram. The frame is drawn to cover the lifelines involved in the
interaction. You can define parameters and a return value
|
sd
|
Sequence diagram: Used to surround an
entire sequence diagram.
|
- A collaboration diagram emphasizes the organization of the objects that participate in an interaction
- They are isomorphic to sequence diagrams, i.e., any sequence diagram can be written as collaboration diagram and vice versa
- Numbering of the messages can be flat
Example: 1,1, 1, 1.2, ... 2, 2.1, 2.2, ...
Uses
Interaction diagram is used:
- To model flows of control by time ordering
- To model flows of control by organization
Post a Comment
Post a Comment