0% found this document useful (0 votes)
50 views43 pages

Interaction Diagrams

The document discusses UML interaction diagrams, specifically sequence diagrams and collaboration diagrams. It provides an overview of interaction diagrams, noting they describe interactions among model elements and represent dynamic system behavior through messages. Sequence diagrams emphasize the time sequence of messages while collaboration diagrams emphasize the structural organization of objects. The document then discusses how to draw these diagrams, including identifying participating objects, message flows, and sequence or organization. It provides examples of both a sequence diagram and collaboration diagram.

Uploaded by

Isha Thakre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views43 pages

Interaction Diagrams

The document discusses UML interaction diagrams, specifically sequence diagrams and collaboration diagrams. It provides an overview of interaction diagrams, noting they describe interactions among model elements and represent dynamic system behavior through messages. Sequence diagrams emphasize the time sequence of messages while collaboration diagrams emphasize the structural organization of objects. The document then discusses how to draw these diagrams, including identifying participating objects, message flows, and sequence or organization. It provides examples of both a sequence diagram and collaboration diagram.

Uploaded by

Isha Thakre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 43

UML - Interaction Diagrams

Overview:
 From the name Interaction it is clear that the diagram is used to
describe some type of interactions among the different elements in
the model. So this interaction is a part of dynamic behaviour of the
system.

 This interactive behavior is represented in UML by two diagrams


known as:
 Sequence diagram and Collaboration diagram.
 The basic purposes of both the diagrams are similar.

 Sequence diagram emphasizes on time sequence of messages and


collaboration diagram emphasizes on the structural organization of
the objects that send and receive messages.
How to draw Interaction Diagram?
The purpose of interaction diagrams are to capture the dynamic aspect of a
system. So to capture the dynamic aspect we need to understand what a dynamic
aspect is and how it is visualized. Dynamic aspect can be defined as the snap
shot of the running system at a particular moment.

We have two types of interaction diagrams in UML. One is sequence diagram and
the other is a collaboration diagram. The sequence diagram captures the time
sequence of message flow from one object to another and the collaboration
diagram describes the organization of objects in a system taking part in the
message flow.

So the following things are to identified clearly before drawing the interaction
diagram:
 Objects taking part in the interaction.
 Message flows among the objects.
 The sequence in which the messages are flowing.
 Object organization.

Following are two interaction diagrams modeling order management system. The
first diagram is a sequence diagram and the second is a collaboration diagram.
UML – Sequence Diagrams
Sequence Diagrams
A sequence diagram emphasizes the time ordering of messages.
The sequence diagram will be formed by first placing the objects
that participated in the interaction at the top of the diagram,
along the x-axis.
Place the objects which initiates the interaction at the left and
increasingly more subordinate objects to the right.
A sequence diagram shows object interactions arranged in time
sequence. It is a construction of message sequence chart.
Sequence diagram are sometimes called event diagrams or
event scenarios.
Sequence Diagram Notations
Actors – An actor in a UML diagram
represents a type of role where it interacts
with the system and its objects. It is
important to note here that an actor is
always outside the scope of the system we
aim to model using the
We use actors to depict various roles including human users and other
external subjects. We represent an actor in a UML diagram using a
stick person notation. We can have multiple actors in a sequence
diagram. For example – Here the user in seat reservation system is
shown as an actor where it exists outside the system and is not a part
of the system.

an actor interacting with a seat reservation system


 Lifelines – A lifeline is a named element which depicts an individual
participant in a sequence diagram. So basically each instance in a
sequence diagram is represented by a lifeline. Lifeline elements are
located at the top in a sequence diagram. The standard in UML for
naming a lifeline follows the following format – Instance Name :
Class Name
 We display a lifeline in a rectangle called head with its name and
type. The head is located on top of a vertical dashed line (referred to
as the stem) as shown above. If we want to model an unnamed
instance, we follow the same pattern except now the portion of
lifeline’s name is left blank. Difference between a lifeline and an
actor – A lifeline always portrays an object internal to the system
whereas actors are used to depict objects external to the system.
 Messages – Communication between objects is depicted using
messages. The messages appear in a sequential order on the
lifeline. We represent messages using arrows. Lifelines and
messages form the core of a sequence diagram. Messages can be
broadly classified into the following categories :
1) Synchronous messages – A synchronous message waits for a
reply before the interaction can move forward. The sender waits
until the receiver has completed the processing of the message.
The caller continues only when it knows that the receiver has
processed the previous message i.e. it receives a reply message.
A large number of calls in object oriented programming are
synchronous. We use a solid arrow head to represent a
synchronous message.
Asynchronous Messages
2) Asynchronous Messages – An asynchronous message does not
wait for a reply from the receiver. The interaction moves forward
irrespective of the receiver processing the previous message or not.
We use a lined arrow head to represent an asynchronous message.
Create message
 Create message – We use a Create message to instantiate a new
object in the sequence diagram. There are situations when a
particular message call requires the creation of an object. It is
represented with a dotted arrow and create word labelled on it to
specify that it is the create Message symbol. For example – The
creation of a new order on a e-commerce website would require a
new object of Order class to be
Delete Message – We use a Delete Message to delete an object.
When an object is deallocated memory or is destroyed within the
system we use the Delete Message symbol. It destroys the occurrence
of the object in the system.It is represented by an arrow terminating
with a x. For example – In the scenario below when the order is
received by the user, the object of order class can be destroyed.
Self Message

 Self Message – Certain scenarios might arise where the object


needs to send a message to itself. Such messages are called Self
Messages and are represented with a U shaped arrow.
Reply Message
 Reply Message – Reply messages are used to show the message
being sent from the receiver to the sender. We represent a
return/reply message using an open arrowhead with a dotted line.
The interaction moves forward only when a reply message is sent
by the receiver.

 For example – Consider the scenario where the device requests a


photo from the user. Here the message which shows the photo
being sent is a reply
 Found Message – A Found message is used to represent a
scenario where an unknown source sends the message. It is
represented using an arrow directed towards a lifeline from an end
point. For example: Consider the scenario of a hardware failure .
The Sequence Diagram

 The sequence diagram is having four objects (Customer, Order,


SpecialOrder and NormalOrder).
 The following diagram has shown the message sequence for
SpecialOrder object and the same can be used in case of
NormalOrder object.
 Now it is important to understand the time sequence of message
flows. The message flow is nothing but a method call of an object.
The first call is sendOrder () which is a method of Order object. The next call
is confirm () which is a method of SpecialOrder object and the last call
is Dispatch () which is a method ofSpecialOrder object. So here the diagram is
mainly describing the method calls from one object to another and this is also
the actual scenario when the system is running.
Sequence Diagram of an Online Exam System
Sequence Diagram Example of a School Management System
The Collaboration Diagram:
Collaboration diagrams are also interaction diagrams. They
convey the same information as Sequence diagrams, but
they focus on object roles instead of the times that
messages are sent.
The collaboration diagram is used to show the relationship
between the objects in a system. Both the sequence and
the collaboration diagrams represent the same information
but differently. Instead of showing the flow of messages, it
depicts the architecture of the object residing in the
system as it is based on object-oriented programming.
An object consists of several features. Multiple objects
present in the system are connected to each other. The
collaboration diagram, which is also known as a
communication diagram, is used to portray the object's
architecture in the system.
Notations of a Collaboration Diagram
Following are the components of a component diagram that are
enlisted below:

Objects: The representation of an object is done by an object


symbol with its name and class underlined, separated by a
colon.
In the collaboration diagram, objects are utilized in the following
ways:
The object is represented by specifying their name and class.
It is not mandatory for every class to appear.
In the collaboration diagram, firstly, the object is created, and
then its class is specified. To differentiate one object from
another object, it is necessary to name them.
Actors: In the collaboration diagram, the actor plays the main
role as it invokes the interaction. Each actor has its respective
role and name. In this, one actor initiates the use case.

Links: The link is an instance of association, which associates


the objects and actors. It portrays a relationship between the
objects through which the messages are sent. It is represented
by a solid line. The link helps an object to connect with or
navigate to another object, such that the message flows are
attached to links.

Messages: It is a communication between objects which carries


information and includes a sequence number, so that the activity
may take place. It is represented by a labeled arrow, which is
placed near a link. The messages are sent from the sender to
the receiver, and the direction must be navigable in that
particular direction. The receiver must understand the message.
Steps for creating a Collaboration
Diagram
1. Determine the behavior for which the realization and
implementation are specified.
2. Discover the structural elements that are class roles, objects,
and subsystems for performing the functionality of
collaboration.
1. Choose the context of an interaction: system, subsystem,
use case, and operation.
3. Think through alternative situations that may be involved.
1. Implementation of a collaboration diagram at an instance
level, if needed.
2. A specification level diagram may be made in the instance
level sequence diagram for summarizing alternative
situations.
Where to use Interaction Diagrams?
 The interaction diagrams are used to describe dynamic nature of a
system. The main purposes of both the diagrams are similar as they
are used to capture the dynamic behaviour of a system. But the
specific purposes are more important to clarify and understood.
 Sequence diagrams are used to capture the order of messages
flowing from one object to another. And the collaboration diagrams
are used to describe the structural organizations of the objects
taking part in the interaction. A single diagram is not sufficient to
describe the dynamic aspect of an entire system so a set of
diagrams are used to capture is as a whole.
 The interaction diagrams are used when we want to understand the
message flow and the structural organization. Now message flow
means the sequence of control flow from one object to another and
structural organization means the visual organization of the
elements in a system.

You might also like