UML Sequence Diagram
description
Transcript of UML Sequence Diagram
UML SEQUENCE DIAGRAM
Concepts & Notations
Acknowledgements The material in this tutorial is
based in part on:
The Unified Modeling Language Reference Manual, 2nd edition, by James Rumbaugh, Ivar Jacobson, and Grady Booch
UML Sequence Diagram
Interaction View Interaction Diagram Sequence Diagram Examples
Interaction View Objects interact to implement behavior
Two ways to describe interactionfocus on individual objects (state machine)focus on interactions of a collection of
cooperating objects (interaction view)
Provides a more holistic view of the behavior of a set of objects
Interaction Diagram Collaboration Diagram
Emphasizes structural relations between objects
Sequence DiagramIllustrates how objects interacts with each
otherEmphasizes time ordering of messages
Sequence Diagram
member:LibraryMember book:Book :Book
Copy
borrow(book)ok = mayBorrow()
[ok] borrow(member)setTaken(member)
Sequence Diagram
member:LibraryMember book:Book :Book
Copy
borrow(book)ok = mayBorrow()
[ok] borrow(member)setTaken(member)
X-Axis (roles)
Y-Axis (tim
e)
Sequence Diagram
member:LibraryMember book:Book :Book
Copy
borrow(book)ok = mayBorrow()
[ok] borrow(member)setTaken(member)
X-Axis (roles)
Y-Axis (tim
e)
head symbol
life line
Sequence Diagram
member:LibraryMember book:Book :Book
Copy
borrow(book)ok = mayBorrow()
[ok] borrow(member)setTaken(member)
X-Axis (roles)
Y-Axis (tim
e)
head symbol
life line
activation double line
Object Naming
syntax[instance Name]:[class Name]
Life linerepresents the object’s life during the
interaction
bDay:Date
Object Active Object
holds the root of a stack executionshas its own thread of control
Passive Objectobjects that are called by an active objectreceive control only when called
Object
pull
pull
: Queueactor1 : … actor2 : …
active object active objectpassive object
Message An interaction between two objects
operation callsignalingRPC
An arrow between the life lines of two objects
Labeled withnameargumentscontrol information
Message
pull
pull
: Queueactor1 : … actor2 : …
message
message
Synchronous Message The routine that handles the message is
completed before the caller resumes execution
:A :B
doYouUnderstand()Caller
Blocked
return (optional
)
yes
synchronous message
Creation Message An object may create another object via
a create() message
old:A
create() :B
Preferredcreate
message
Destruction Message An object may destroy another object
via a destroy() message
old:A new:B
destroy()
Examples
print(doc,client)Client
:PrintServer :Queue :PrinterProxy
enqueue(job)
status
job=dequeue()
[job]print(job.doc)
[job] done(status)
Repeated forever with 1 min interludes
Examples
print(doc,client)Client
:PrintServer :Queue :PrinterProxy
enqueue(job)
status
job=dequeue()
[job]print(job.doc)
[job] done(status)
Repeated forever with 1 min interludes
Examples
print(doc,client)Client
:PrintServer :Queue :PrinterProxy
enqueue(job)
status
job=dequeue()
[job]print(job.doc)
[job] done(status)
Repeated forever with 1 min interludes
Examples
print(doc,client)Client
:PrintServer :Queue :PrinterProxy
enqueue(job)
status
job=dequeue()
[job]print(job.doc)
[job] done(status)
Repeated forever with 1 min interludes
Examples
print(doc,client)Client
:PrintServer :Queue :PrinterProxy
enqueue(job)
status
job=dequeue()
[job]print(job.doc)
[job] done(status)
Repeated forever with 1 min interludes
Examples
print(doc,client)Client
:PrintServer :Queue :PrinterProxy
enqueue(job)
status
job=dequeue()
[job]print(job.doc)
[job] done(status)
Repeated forever with 1 min interludes
Examples
print(doc,client)Client
:PrintServer :Queue :PrinterProxy
enqueue(job)
status
job=dequeue()
[job]print(job.doc)
[job] done(status)
Repeated forever with 1 min interludes
Review Time on y-axis, roles on x-axis Activation bars represent executions of
procedures Active objects have bars Solid arrowheads: synchronous Stick arrowheads: asynchronous Dashed message lines: return
:PrintServer