Professional Documents
Culture Documents
Lec 8 SREE
Lec 8 SREE
Lec 8 SREE
Software Re-Engineering
Lecture: 08
Sequence [Todays Agenda]
Content of Lecture
•Sequence Diagram
•Collaboration Diagram
Types of Interaction diagrams
1. Sequence Diagram
2. Collaboration Diagram
Sequence Diagram (make a phone
call)
:Caller :Phone :Recipient
Picks up()
Dial tone()
Dial () Ring(
)
Ring notification ()
Picks up()
Hello() Hello()
Representing
Objects
Squares with object type, optionally preceded by
"name :"
–write object's name if it clarifies the diagram
–object's "life line" represented by dashed vert. line
Messages Between
Objects
messages (method calls) indicated by arrow
to other object
– write message name and arguments above
arrow
Lifetime of
creation: objects
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
–Java doesn't explicitly delete
objects; they fall out of scope
and are garbage-collected
Selection and
frame: box around part of
loops
diagram to indicate if or loop
– if ->
[condition] (opt)
– if/else -> (alt)
[condition], separated
by horizontal dashed
line
– loop -> (loop)
[condition or items to
loop over]
Sequence diagram from use case
scenario
Collaboration
Diagram
1
Collaboration Diagrams
• Dynamic behavior of objects can, in addition to
sequence diagrams, also be represented by
collaboration diagrams.
• The transformation from a sequence diagram into
a collaboration diagram is a bi-directional function.
• The difference between sequence diagrams and
collaboration diagrams is that collaboration
diagrams emphasize more the structure than the
sequence of interactions.
• Within sequence diagrams the order of
interactions is established by vertical positioning
whereas in collaboration diagrams the sequence
is given by numbering the interactions.
14
Sequence Diagram (Example)
Collaboration Diagrams
16
Fun Example Sequence
diagram
18
Fun Example Sequence
diagram
19
Fun Example Collaboration
diagram
20
When to use Interaction Diagrams
21
Class Activity
Class Activity
24