0% found this document useful (0 votes)
81 views

Sequence Diagrams: Massimo Felici Room 1402, JCMB, KB 0131 650 5899 Mfelici@inf - Ed.ac - Uk

Sequence Diagrams are interaction diagrams that detail how operations are carried out. They capture the interaction between objects in the context of a collaboration. They don't show the structural relationships between objects. They show the order of the interaction visually by using the vertical axis of the diagram to represent time what messages are sent and when.

Uploaded by

api-26462544
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

Sequence Diagrams: Massimo Felici Room 1402, JCMB, KB 0131 650 5899 Mfelici@inf - Ed.ac - Uk

Sequence Diagrams are interaction diagrams that detail how operations are carried out. They capture the interaction between objects in the context of a collaboration. They don't show the structural relationships between objects. They show the order of the interaction visually by using the vertical axis of the diagram to represent time what messages are sent and when.

Uploaded by

api-26462544
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Sequence Diagrams

Massimo Felici
Room 1402, JCMB, KB
0131 650 5899
[email protected]
What are Sequence Diagrams?
ƒ Sequence Diagrams are interaction diagrams that
detail how operations are carried out
• Interaction diagrams model important runtime interactions
between the parts that make up the system
ƒ Sequence Diagrams
• capture the interaction between objects in the context of a
collaboration
• show object instances that play the roles defined in a
collaboration
• don’t show the structural relationships between objects
• show the order of the interaction visually by using the
vertical axis of the diagram to represent time what
messages are sent and when

© 2004-2006 SEOC - Lecture Note 12 2


What Do Sequence Diagrams Model?
ƒ Model high-level interaction ƒ Capture the interaction that
between active objects in a takes place in a collaboration
system that either realizes a use case
ƒ Model the interaction between or an operation (instance
object instances within a diagrams or generic diagrams)
collaboration that realizes a ƒ Capture high-level interactions
use case between user of the system and
ƒ Model the interaction between the system, between the system
objects within a collaboration and other systems, or between
that realizes an operation subsystems (sometimes known as
ƒ Either model generic system sequence diagrams)
interactions (showing all
possible paths through the
interaction) or specific
instances of a interaction
(showing just one path through
the interaction

© 2004-2006 SEOC - Lecture Note 12 3


Sequence Diagrams at a Glance
Sequence Diagrams
show elements as they
interact over time,
showing interactions
or interaction
instances

© 2004-2006 SEOC - Lecture Note 12 4


Participants in a Sequence Diagram
ƒ A sequence diagram is ƒ In UML 1.x,
made up of a collection participants were
of participants usually software objects
(instances of classes) in
ƒ Participants- the
object- oriented
system parts that
programming sense
interact each other
during the sequence ƒ In UML 2.0, as general
modeling language,
ƒ Classes or Objects:
participants are also at
each object (class) in
the level of system
the interaction is
parts
represented by its
named icon along the top
of the diagram
© 2004-2006 SEOC - Lecture Note 12 5
Time in a Sequence Diagram
ƒ Sequence diagrams are
organized according to time
ƒ Each participant has a
corresponding lifeline
ƒ Lifelines: each vertical dotted
line is a lifeline, representing
the time that an object exists
ƒ Activations: an activation (shown
as tall, thin rectangle on a
lifeline) represents the period
during which an element is
performing an operation. The
top and the bottom of the of ƒ Notes
the rectangle are aligned with • Time in a sequence diagram is all
the initiation and the a about ordering, not duration
completion time respectively • The vertical space in an
interaction diagram is not
relevant for the duration of the
interaction

© 2004-2006 SEOC - Lecture Note 12 6


Sequence Diagrams’ Dimensions
ƒ Objects
• The horizontal axis shows Objects
the elements that are
involved in the interaction
• Conventionally, the
objects involved in the
operation are listed from
left to right according to
when they take part in
the message sequence
• However, the elements on
the horizontal axis may
appear in any order

Time
ƒ Time
• The vertical axis
represents time
proceedings (or
progressing) down the
page
© 2004-2006 SEOC - Lecture Note 12 7
Events, Signals and Messages
ƒ An Event is any point in an
interaction where something
occurs
ƒ Signals and Messages are
similar concepts
• Messages on a sequence
diagram are specified using
an arrow from the
participant (message caller)
that wants to pass the
message to the participant
(message receiver) that is to
receive the message
• Messages: a message (or
stimulus) is represented as
an arrow going from the
sender to the top of the
activation bar of the
message on the receiver's
lifeline
© 2004-2006 SEOC - Lecture Note 12 8
Types of Messages
ƒ Reflexive Communications: similar to a reflexive association or link,
an element may communicate with itself where communication is
sent from the element to itself. Sending messages to itself means
an object has two activations simultaneously.
ƒ Repetitions: involve repeating a set of messages or stimuli within a
generic-form interaction. Messages are grouped together in a
rectangle. The expression in square brackets, [ ], is a condition. The
asterisk “*” means iteration.
ƒ Conditionality: branching results in a choice of two different
messages (or operation calls) being sent to the same object, the
lifeline of the object splits with two activations. The separate
lifelines merge back together after the completion of different
actions in response to the different messages.
ƒ Return Values: often worthwhile to label the return value because
it may be used later in the interaction

© 2004-2006 SEOC - Lecture Note 12 9


Creation and Destruction Messages
ƒ Element Creation: when an
element is created during an
interaction, the communication
that creates the element is
shown with its arrowhead to
the element

ƒ Element Destruction: When an


element is destroyed during an
interaction, the communication
that destroys the element is
shown with its arrowhead to
the element’s lifeline where the
destruction is marked with a
large X symbol

© 2004-2006 SEOC - Lecture Note 12 10


Timing
ƒ Sequence Diagrams easily ƒ Durations. The duration
deal with Timing information of activations or the
ƒ Constraints: are usually used time between messages
to show timing constraints on can be show with
messages. They can apply to construction marks.
the timing of one message or • Metric information in the
intervals between messages. diagram contribute to
• Label the points of issue and
representing timing, but
return for a message. Use
these labels in expressing this is not recommended
timing constraints. (why not?)
• This technique also works • Although if the line
for message sending that representing the message
takes time (so arrows are is horizontal, it is unclear
sloping down). whether it applies to the
time the message is sent
or received

© 2004-2006 SEOC - Lecture Note 12 11


A Sequence Diagram with Timing

© 2004-2006 SEOC - Lecture Note 12 12


Sequence Fragments
fragment
ƒ UML 2.0 introduces operator The sequence
fragment box
Sequence (or Interaction)
Fragments
ƒ A sequence fragment is
represented as a box, called
a combined fragment, which
encloses a portion of the
interactions within a
sequence diagram
ƒ Sequence fragments
ƒ The fragment operator (in make it easier to create
the top left cornet) indicates
the type of fragment
and maintain accurate
sequence diagrams
ƒ Fragment types: ref, assert,
loop, break, alt, opt, neg

© 2004-2006 SEOC - Lecture Note 12 13


How to Produce Sequence Diagrams
1. Decide on Context: Identify behavior (or
use case) to be specified
2. Identify structural elements:
1. Model objects (classes)
2. Model lifelines
3. Model activations
4. Model messages
5. Model Timing constraints
3. Refine and elaborate as required

© 2004-2006 SEOC - Lecture Note 12 14


How do interaction diagrams help?
ƒ Check use cases: this is the main
emphasized aspect
ƒ Check class can provide an operation:
shows how a class realizes some operation
by interacting with other objects
ƒ Describe design pattern: parameterizing by
class provides a scheme for a generic
interaction (part of Software Architecture)
ƒ Describe how to use a component: captures
how components can interact
© 2004-2006 SEOC - Lecture Note 12 15
Summary
ƒ Sequence Diagrams
• capture some elements of the dynamics of systems
• Support a number of different activities
• Describe interaction in some detail, including
timing
ƒ Dimensions: Objects and Time
ƒ Basics: Objects, Lifelines, Activations,
Messages, etc.
ƒ Timing

© 2004-2006 SEOC - Lecture Note 12 16

You might also like