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
![Sequence Diagram cse study zone,estudies4you,Interaction Diagrams,uml Interaction Diagrams,Interaction Diagrams in uml.ooad Interaction Diagrams,Interaction Diagrams in ooad,types of Interaction Diagrams in uml,uml Interaction Diagrams types,Sequence Diagrams in uml,uml Sequence Diagrams,Sequence Diagrams in ooad,ooad Sequence Diagrams,](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCM62Z6SKk_KKTfYjlP0MpEiZ1_42edJqIO9aQ6O9SADGfxxKOOwaGWzysyDcfHwHg4CPhL1IDha9VSCQT3KWL58CxG6lbYx_oE4D4tjDudxAYBJUTbxbTbFFrHL64kZyvupiyqaCdcYtp/s1600/Sequence+diagram+in+uml.png)
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.
![cse study zone,estudies4you,Interaction Diagrams,uml Interaction Diagrams,Interaction Diagrams in uml.ooad Interaction Diagrams,Interaction Diagrams in ooad,types of Interaction Diagrams in uml,uml Interaction Diagrams types,Sequence Diagrams in uml,uml Sequence Diagrams,Sequence Diagrams in ooad,ooad Sequence Diagrams,](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTSaaZDfvHJxmm5AUedL62jibIMg9dMRgAYVRg68tngWbVQTHZHn0h7rYI5Q9gGIsdRMRfZcwWHSVhXtGL6kmFv_Thm51OKO_q1n5DNYkAhqg3uoY6mVnAiv1oGHkjn1iAEgxQNU60ixQd/s1600/Collaboration+diagram.png)
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, ...
![UML Collaboration Diagram](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5Rm1jzr88zdNah1Uq5Spyl8vupKdi2FC0IrXxLxNBvjaWD0Cfgylr_UcEyQuhl9AxPr6C5LdYXcuCmENjIlm8Y1Zi3gizijI8rlPT2MGn8M9QdwqAeyMD0_8xyvXTijnNxEiF23TVSvdq/s1600/uml+collaboration+diagram.png)
Uses
Interaction diagram is used:
- To model flows of control by time ordering
- To model flows of control by organization