Interaction Diagram: Lecture - 13

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 37
At a glance
Powered by AI
The key takeaways are that sequence diagrams illustrate the flow of messages between objects to achieve a particular functionality in a system. They are commonly used during analysis and design to understand logical flow.

The different types of interaction diagrams are sequence diagrams, communication diagrams, and timing diagrams. Sequence diagrams are preferred due to their simplicity.

Benefits of sequence diagrams include representing message flow between objects, being easier to maintain and generate, and allowing both forward and reverse engineering.

1

INTERACTION
DIAGRAM
Lecture - 13
Contents
2

 Interaction diagram
 What is a Sequence Diagram?

 Why not just code it?

 Sequence Diagram Notations

 Purpose of Sequence Diagrams

 Sequence diagram example


Contents
3

 Benefits of a Sequence Diagram


 The drawback of a Sequence Diagram

 How to Draw a Sequence Diagram?

 Sequence Diagram Common Mistakes

 Summary
Interaction diagram
4

 Establish communication between objects.


 It does not manipulate the data associated with the
particular communication path.
 Mostly focus on message passing and how these
messages make up one functionality of a system.
 Display how the objects will realize the particular
requirements of a system.
 The critical component in an interaction diagram is
lifeline and messages
Interaction diagram
5

• Sequence diagrams
• Communication diagrams
• Timing diagrams
 Interaction diagrams are used to illustrate interactions
of parts within a system.
 Out of these 3 types, sequence diagrams are preferred
by both developers and readers alike for their
simplicity.
Sequence Diagram
 Describe the flow of messages, events, actions
between objects
 Show concurrent processes and activations
 Show time sequences that are not easily depicted in
other diagrams
 Typically used during analysis and design to
document and understand the logical flow of your
system

6
What is Sequence diagram?
7

Sequence diagram is interaction diagram that


shows the set of objects and messages send and
receive by those object.
It mainly emphases on time ordering and

messages.
It is used to illustrate the dynamic view of

system.
What is Sequence diagram?
8

 Commonly used by developers, model the


interactions between objects in a single use case.
 They illustrate how the different parts of a system
interact with each other to carry out a function, and
the order in which the interactions occur when a
particular use case is executed.
Why not just code it?
9

 Sequence diagrams can be somewhat close to the code


level.
 So why not just code up that algorithm rather than drawing
it as a sequence diagram?
– a good sequence diagram is still a bit above the level of the real code
(not all code is drawn on diagram)
– sequence diagrams are language-agnostic (can be implemented in
many different languages
– non-coders can do sequence diagrams
– easier to do sequence diagrams as a team
– can see many objects/classes at a time on same page (visual
bandwidth)
Sequence Diagram Notations
10
Objects or Participants
11

 It is made up of collection of participants or objects.


 Participants are system parts that interact each other
during sequence diagram.
 The participants interact with each other by sending
and receiving message
Actor
12

 A lifeline notation with an actor element symbol is


used when the particular sequence diagram is
owned by a use case.
 Shows entities that interact with or are external to
the system.
Lifeline Notation
13

 A sequence diagram is made up of several of these


lifeline notations
 They should be arranged horizontally across the top of
the diagram
 No two lifeline notations should overlap each other
 They represent the different objects that interact with
each other in the system
 A lifeline notation with an actor element symbol is used
when the sequence diagram is owned by a use case
Lifeline
14

 Lifeline represents the existence of an object over a


period of time.
 It is represented by vertical dashed line.
Activation bar
15

 It is also called as focus of


control.
 It shows the period of time during
which an object is performing an
action.
 Activation bar is the box placed
on the lifeline
Activation bar
16

 Activation bar is the box placed on the lifeline.  


 It is used to indicate that an object is active during
an interaction between two objects.
 The length of the rectangle indicates the duration
of the objects staying active.
Messages
17

 The interaction in a sequence diagram between the


objects can be shown by using messages.
 An arrow from the Message Caller to the Message
Receiver specifies a message
 The message can flow in any direction; from left to
right, right to left and back to the caller itself
 The description of the message should go on the arrow
 Arrow heads may change according to different
message types
Messages
18

 Send Message
 Synchronous messages

 Asynchronous messages

 Receive message

 Self Message

 Destroy messages
Send message
19

 It is used to create object during interaction.


 The object can be created by using
<<create>> to indicate the timing of creation.
Synchronous messages
20

 A synchronous message is used when the sender


waits for the receiver to process the message and
return before carrying on with another message
 It is represented by solid line with solid arrowhead.
Asynchronous messages
21

 An asynchronous message is used when the


message caller does not wait for the receiver to
process the message and return before sending
other messages to other objects within the system
 It is represent by solid line with a lined arrowhead.
Reply or Return message
22

 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


Self Message
23

 If the object sends the message to itself then it


is called as self message or reflexive message.
 It is indicated with a message arrow that starts

and ends at the same lifeline.


Destroy messages
24

 It is used to destroy the objects during


interaction.
 Participants when no longer needed can also be
deleted from a sequence diagram.
 This is done by adding an ‘X’ at the end of the
lifeline of the said participant.
Comments
25

 UML generally permits the annotation of


comments in all UML diagram types.
 The comment object is a rectangle with a folded-
over corner as shown below.
 The comment can be linked to the related object
with a dashed line.
Purpose of Sequence Diagrams
26

 To capture the dynamic behaviour of a system.


 To describe the message flow in the system.
 To describe the structural organization of the objects.
 To describe the interaction among objects.
27
Benefits of a Sequence Diagram
28

 Used to explore any real application or a system.


 Represent message flow from one object to another
object.
 Easier to maintain.
 Easier to generate.
 Easily updated according to the changes within a
system.
 Allows reverse as well as forward engineering.
The drawback of a Sequence Diagram
29

 In the case of too many lifelines, the sequence


diagram can get more complex.
 The incorrect result may be produced, if the
order of the flow of messages changes.
 Since each sequence needs distinct notations for its
representation, it may make the diagram more
complex.
 The type of sequence is decided by the type of
message.
How to Draw a Sequence Diagram?
30

 Objects taking part in the interaction.


 Message flows among the objects.

 The sequence in which the messages are

flowing.
 Object organization.
How to Draw a Sequence Diagram
31

 A sequence diagram represents the scenario or flow


of events in one single use case.
 The message flow of the sequence diagram is
based on the narrative of the particular use case.
 Before you start drawing the sequence diagram or
decide what interactions should be included in it,
you need to ready a comprehensive description of
the particular use case.
Example
32

Use case example


– Create new
online library
account
Step -1
33

 Identify the objects or participants in the use case


‘Create New User Account’

Librarian

Online Library Management system


User credentials database

Email system
Step - 2
34

 List down the steps involved in the execution of the use


case
 The librarian request the system to create a new online library
account
 The librarian then selects the library user account type
 The librarian enters the user’s details
 The user’s details are checked using the user Credentials
Database
 The new library user account is created
 A summary of the of the new account’s details are then
emailed to the user
Step -3
35
Sequence Diagram Common Mistakes
36

 Adding too much detail that makes it difficult to


read the diagram.
 Obsolete sequence diagrams that are irrelevant
when compared to the interfaces, actual
architectures of the system
 Leaving no blank space between the use case text
and the message arrow
 Not considering the origins of message arrows
carefully
Summary
37

 The critical elements in an interaction diagram


are lifeline and messages.
 Mostly focus on message passing.

 Capture the dynamic behavior of any system.

 Contains sequence diagram, timing diagram,

communication/collaboration diagram.
 To visualize the sequence of a message flow

in the system.

You might also like