Interaction diagrams
Sequence and collaboration
diagrams
What are interaction diagrams?
An interaction diagram is a
type of UML diagram that's used to capture the
interactive behavior of a system. Interaction
diagrams focus on describing the flow of
messages within a system, providing context
for one or more lifelines within a system.
There are two kinds of interaction diagrams:
collaboration diagrams
sequence diagrams
Collaboration and sequence diagrams:
main differences
Collaboration diagram illustrates object interactions in a
graph or network format, in which objects can be placed
anywhere on the diagram. It demonstrates how objects
are statically connected.
Sequence diagram illustrates interaction in a kind of
fence format, in which each new object is added to the
right. It generally shows the sequence of events that
occur.
Interaction diagrams: when and how to
use them?
1. Identify the system events that are
implied by the use cases.
2. Make at least one interaction diagram for
each system event.
3. Make additional interaction diagrams for
alternative courses of events.
Interaction diagrams: notation
The following notation is used in the UML for classes and
objects:
Class
Person
Instance of a Class
(object without a name) :Person
Named instance of a class
(named object) michael:Person
Named object only
(shown without class) michael
Types of message flows
Synchronous: the sender waits until the responder
finishes.
Flat: the sender doesn't wait for anything from the
responder and finishes its' activity; the control is passed to
the responder.
Asynchronous: the sender doesn't wait for anything from
the responder, but it continues its' own activity.
Collaboration diagrams
A collaboration diagram shows the relationship
between objects and the order of messages
passed between them.
The objects are listed as icons and arrows
indicate the messages being passed between
them.
The numbers next to the messages are called
sequence numbers and, as the name suggests,
they show the sequence of the messages as
they are passed between the objects.
Collaboration diagram – an example
Collaboration diagrams – more complex example
Static model based on previous collaboration diagram
Collaboration diagrams – strenghts and weaknesses
One of the greatest strengths of collaboration diagrams is
their simplicity.
The principal weakness, however, is that although they are
good at describing behavior, they do not define it. They
typically do not show all the iteration and control that is
needed to give an computationally complete description.
Sequence diagrams
A sequence diagram shows relations between
objects.
It should be read from left to right and from top
to bottom.
At the top of the diagram are names of objects
that interact with each other. These are the
concepts in the conceptual model.
When the course of events is initiated by an
actor the actor symbol is displayed as the
leftmost object.
Sequence diagrams: an example
: object1 : object2 : object3
: Custom er
Acto
r
Instance
s of
classes
Sequence Diagram: Lifelines
:actor :object1 :object2 :object
3
Time
Each object has a lifeline.
Time flows from top to down.
Sequence diagrams: rectangles
:actor :object1
Time :object2 :object3
Rectangles refer to events that
are related to each other.
Sequence diagrams: messages
:actor :object1
Time :object2 :object3
Arrows indicate messages that
are sent from one object to
another.
Sequence diagrams - different types of messages
: object1 : o bject2 : object3
: Custom er
req uest( )
createObject3( )
Messag
create( )
e
An object
sends a
message to
Feedback itself.
arrow shows
that a value is
returned.
Sequence diagrams: endpoints
: object1 : o bject2 : object3
: Custom er
request( )
createObject3( )
create( )
X at the end of
the lifeline
shows that the
object ceases
to exist.
Sequence diagram: a more complex example
: Res ervationSys tem : Authoris ationSys tem : VideoCopy : VideoSpecification : Bo okedIte ms Li st
: Cus tom er
lookFor(title)
che ckVali dity()
checkAvailibility(title)
che ckAvaili bili ty(titl e)
createBookedItem s Lis t( )
create( )
add()
Sequence diagrams - strengths and
weaknesses
Strengths:
- they clearly show sequence or time ordering of
messages
- the notation is rather simple
Weaknesses:
- forced to extend to right when adding new
objects, consumes a lot of space
Use Cases and Actors
A use case
Specifiesthe behavior of a system
Represents a functional requirement of your
system as a whole
Describes what a system not how it does it
An actor
Represents users of use case play when
interacting with use cases
It’s not part of the system
Use Cases and Actors
Organizing Use Cases
Organize use case by specifying
Generalization
Include
The base use case pulling behavior from the
supplier use case
Extend
Pushing behavior to the base use case
Use Case Diagrams
A use case diagram
A diagram shows a set of use cases and
actors and their relationship
Contents
Use cases
Actors
Dependency, generalization, and association
relationships
Use Case Diagrams
Activity Diagrams
Activity diagrams represent the dynamics of the system.
They are flow charts that are used to show the workflow
of a system.
They show.
The flow of control from activity to activity in the system,
What activities can be done in parallel.
Alternate paths through the flow.
They can show the flow across use cases or within a use
case.
Core symbol is an activity.
Activity Diagram
An activity is some task which needs to be
done.
Each activity can be followed by another
activity (sequencing).
Triggers from the activity may be guarded
as in state diagrams.
Decision Activities
Diamond.
Each trigger coming from it has a guard.
Synchronisation bar.
All triggers from this attach to activities that can
occur in parallel, with no specific sequence, or
concurrently.
The next synchronisation bar closes the
concurrency.
Iteration is represented by a * on the trigger.
Activity Diagram Example
Swimlane
Arrange activity diagrams into vertical
zones separated by dashed lines.
Each zone represents the responsibilities
of a particular class or department.
Swimlane Example
Use Case Diagram:- Library Management System
Activity Diagram for Issue Book in Library
Activity Diagram for Return Book in Library:-
Collaboration diagram for issuing Book:
Collaboration diagram for returning Book:
Sequence diagram for issuing book:
Sequence diagram for returning book:
THANK YOU