Download - 07-Uml Sequence Diagrams
-
8/3/2019 07-Uml Sequence Diagrams
1/16
1
TCSS 360, Spring 2005Lecture Notes
UML Sequence Diagrams
Relevant Reading:UML Distilled, Third Edition , Chapter 4
M. Fowler
-
8/3/2019 07-Uml Sequence Diagrams
2/16
2
UML sequence diagrams
sequence diagram : an "interaction diagram" that models asingle scenario executing in the systemperhaps 2nd most used UML diagram (behind class diagram)
A sequence diagram is an interaction diagram that emphasizesthe time ordering of messages. It shows a set of objects andthe messages sent and received by those objects.
Graphically, a sequence diagram is a table that shows objects
arranged along the X axis and messages, ordered in increasingtime, along the Y axis.
relation of UML diagrams to other exercises:CRC cards -> class diagramuse cases -> sequence diagrams
-
8/3/2019 07-Uml Sequence Diagrams
3/16
3
Key parts of a sequence diag.
participant : an object or entity that acts in the sequencediagramsequence diagram starts with an unattached "foundmessage" arrow
message : communication between participant objects
the axes in a sequence diagram:
horizontal: which object/participant is actingvertical: time (down -> forward in time)
-
8/3/2019 07-Uml Sequence Diagrams
4/16
4
Sequence Diagram
An object in a sequence diagram is rendered
as a box with a dashed line descending from it.
The line is called the object lifeline , and itrepresents the existence of an object over a
period of time.
an Order Line
-
8/3/2019 07-Uml Sequence Diagrams
5/16
5
Sequence diag. from use case
-
8/3/2019 07-Uml Sequence Diagrams
6/16
6
o a ora on agramSequence Diagram
Both a collaboration diagram and a sequence diagram derivefrom the same information in the UMLs metamodel, so you cantake a diagram in one form and convert it into the other. Theyare semantically equivalent.
-
8/3/2019 07-Uml Sequence Diagrams
7/167
Representing objects
squares with object type, optionally precededby object name and colonwrite object's name if it clarifies the diagramobject's "life line" represented by dashed vert. line
-
8/3/2019 07-Uml Sequence Diagrams
8/168
message (method call) indicated by horizontal arrowto other objectwrite message name and arguments above arrow
dashed arrow back indicates returndifferent arrowheads for normal / concurrent (asynchronous)
methods
Messages between objects
-
8/3/2019 07-Uml Sequence Diagrams
9/169
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 finishnest to indicate recursionActivation
Nesting
-
8/3/2019 07-Uml Sequence Diagrams
10/1610
linking sequence diagrams
if one sequence diagram is too large or refers toanother diagram, indicate it with either:an unfinished arrow and commenta "ref" frame that names the other diagram
when would this occur in our system?
Verify customer credit
refCustomer Info
Approved?
-
8/3/2019 07-Uml Sequence Diagrams
11/1611
Example sequence diagram
sd Example
loop
StoreFront Cart Inventory
AddItemReserveItem
PlaceItemInOrder
Checkout
ProcessOrderConfirmOrder
-
8/3/2019 07-Uml Sequence Diagrams
12/1612
(De)centralized system control
What can you say about the control flow of each of the following systems?centralized?distributed?
-
8/3/2019 07-Uml Sequence Diagrams
13/1613
Flawed sequence diagram 1
What's wrong with this sequence diagram? (Look atthe UML syntax and the viability of the scenario.)
-
8/3/2019 07-Uml Sequence Diagrams
14/1614
Flawed sequence diagram 2
What's wrong with this sequence diagram?
-
8/3/2019 07-Uml Sequence Diagrams
15/1615
Flawed sequence diagram 3
What's wrong with this sequence diagram?
:Computer :PrintServer :Printer :Queue
print(file)[if printer free] print(file)
[else] enqueue(file)
-
8/3/2019 07-Uml Sequence Diagrams
16/1616
Why not just code it?
Sequence diagrams can be somewhat close tothe code level. So why not just code up thatalgorithm rather than drawing it as a sequence
diagram?a good sequence diagram is still a bit above the level of thereal code (not EVERY line of code is drawn on diagram)sequence diagrams are language-agnostic (can be
implemented in many different languagesnon-coders can do sequence diagramseasier to do sequence diagrams as a teamcan see many objects/classes at a time on same page(visual bandwidth)