10 InteractionModeling
10 InteractionModeling
Interaction Model
• The class model describes the objects in a system
and their relationships
• The state model describes the life cycles of the
objects
• The interaction model describes how the objects
interact
• Both state model and interaction model are
needed to describe behavior fully. They view
behavior from different perspective
Interaction Model
• Can be modelled at different level of
abstraction
– At high level, Use cases describes how a system
interacts with outside actors
– Sequence diagrams provide more detail and show
the messages exchanged among a set of objects
over time
– Activity diagrams provide details and show the
flow of control among the steps of a computation
Sequence Diagram
• Sequence diagram
– Shows the participants in an interaction and the
sequence of messages among them
– Shows the interaction of a system with its actors to
perform all or part of a use case
Key parts of a Sequence Diagram
• participant: an object or entity that acts in the
sequence diagram
• message: communication between participant
objects
• The axes in a sequence diagram:
– horizontal: which object/participant is acting
– vertical: lifeline ( time – top -> bottom ) (spacing is
irrelevant)
Representing objects
• Squares with object type, optionally preceded
by object name and colon
– write object's name if it clarifies the diagram
– object's "life line" represented by dashed vert. line
Messages between objects
• message (method call) indicated by horizontal
arrow to other object
– write message name and arguments above arrow
Messages, continued
• message (method call) indicated by horizontal
arrow to other object
– dashed arrow back indicates return
– different arrowheads for normal / concurrent
(asynchronous) methods
Lifetime of objects
• creation: arrow
with 'new' written
above it
– notice that an object
created after the
start of the scenario
appears lower than
the others
• deletion: an X at
bottom of object's
lifeline
Indicating method calls
• activation: thick box over object's life line;
drawn when object's method is on the stack
– either that object is running its code, or it is on the
stack waiting for another object's method to finish
– nest to indicate recursion
Activation
Nesting
Indicating selection and loops
• frame: box around part of a sequence diagram to indicate selection or
loop
– if -> (opt) [condition]
– if/else -> (alt) [condition], separated by horizontal dashed line
– loop -> (loop) [condition or items to loop over]