www.ddss.arch.tue.nl 7m822 uml sequence diagrams 2 december 2010
Post on 20-Dec-2015
223 views
TRANSCRIPT
www.ddss.arch.tue.nl
7M822
UML DiagramsUML Diagrams
• Structure diagram– Class diagram– Object diagram– Component diagram– Deployment diagram– Package diagram
• Behaviour diagram– Use Case diagram– Activity diagram– Interaction diagram
• Sequence diagram• Communication diagram
2
www.ddss.arch.tue.nl
7M822
In a nutshell: what are interactions?In a nutshell: what are interactions?
• A collection of communications between instances, including all ways to affect instances, like operation invocation, as well as creation and destruction of instances
• The communications are partially ordered (in time)
3
www.ddss.arch.tue.nl
7M822
Interaction Diagram GuideInteraction Diagram Guide
• Show interactions between instances in the model– graph of instances (possibly including links) and stimuli– existing instances– creation and deletion of instances
• Kinds– Sequence diagram (temporal focus) – Communication diagram (structural focus)
4
www.ddss.arch.tue.nl
7M822
Interaction DiagramsInteraction Diagrams
5
x y z
Sequence Diagram
a
b
c
Communication Diagram
x y
z
1.1: a1.2: c
1.1.1: b
www.ddss.arch.tue.nl
7M822
Different Kinds of ArrowsDifferent Kinds of Arrows
Procedure call or other kind of nested flow of control (synchronous message)
Return
Asynchronous message
Asynchronous message in UML 1.x
6
www.ddss.arch.tue.nl
7M822
Lifeline & MessagesLifeline & Messages
• The vertical line is called the object’s lifeline. The lifeline represents the object’s life during the interaction.
• Each message is represented by an arrow between the lifelines of two objects.
• The order in which these messages occur is shown top to bottom.
• Each message is labeled at minimum with the message name; also arguments and some control information can be included.
• A self-back is a message that an object sends to itself, by sending the message arrow back to the same lifeline.
7
www.ddss.arch.tue.nl
7M822
Sequence Diagram / Communication DiagramSequence Diagram / Communication Diagram
8
an Order an Order Line aProduct aCustomer
calculatePricegetQuantity
getProduct
aProduct
getPricingDetails
calculateBasePrice
calculateDiscounts
getDiscountInfo
found message
return
self-call
activation
lifeline
message
participant
an Order aCustomer
an Order Line aProduct
1: calculatePrice
1.5.1: getDiscountInfo
1.3: getPricingDetails
1.4: calculateBasePrice()1.5: calculateDiscounts()
1.1: getQuantity()1.2: getProduct()
www.ddss.arch.tue.nl
7M822
Sequence Diagram vs. Communication DiagramSequence Diagram vs. Communication Diagram
• Sequence diagrams are used when you want to look at the behavior of several objects within a single use case. Sequence diagrams are good at showing collaborations among the objects.
• Communication diagrams emphasize the data links between the various participants in the interaction. With communication diagrams we can show how the participants are linked together.
9
www.ddss.arch.tue.nl
7M822
Elements Sequence DiagramsElements Sequence Diagrams
10
Participant : Object
Participant / ObjectLifeline Activation Lifeline
Message Message Self back
Return Return
{}
Constraint Comment
www.ddss.arch.tue.nl
7M822
Next Concepts Sequence Diagrams 1of2Next Concepts Sequence Diagrams 1of2
11
:Computer :PrinterServer :Printer :Queue
PrintPrint(file)
[printer available] Print(file)
[printer working] Save(file)
control guard
www.ddss.arch.tue.nl
7M822
Next Concepts Sequence Diagrams 2of2Next Concepts Sequence Diagrams 2of2
12
:Computer :PrinterServer :Printer
PrintPrint(file)
Print(file){
ab-a < 5 sec
bb'-b < 1 sec
b' }
constraint
www.ddss.arch.tue.nl
7M82213
: Order Entry Window : Order Line: Order : Stock Item
: Reorder Item
: Delivery Item
SEQUENCEDIAGRAM
www.ddss.arch.tue.nl
7M82214
: Transaction
: Transaction Coordinator
: first Transaction Checker
: second Transaction Checker Concurrent
Processes andActivations
www.ddss.arch.tue.nl
7M82215
: Transaction
: Transaction Coordinator
: first Transaction Checker
: second Transaction Checker
SEQUENCEDIAGRAM:Check Failure
www.ddss.arch.tue.nl
7M82217
Use Case Description: Change Flt ItineraryUse Case Description: Change Flt Itinerary• Actors: traveler, client account db, airline reservation
system• Preconditions: Traveler has logged in• Basic course:
– Traveler selects ‘change flight itinerary’ option– System retrieves traveler’s account and flight itinerary from client account database– System asks traveler to select itinerary segment she wants to change; traveler selects
itinerary segment.– System asks traveler for new departure and destination information; traveler provides
information.– If flights are available then …– …– System displays transaction summary.
• Alternative course:– If no flights are available then…
www.ddss.arch.tue.nl
7M82218
Sequence Diagram: Change Flight ItinerarySequence Diagram: Change Flight Itinerary
: Booking SystemTraveler Airline Reservation System
change flight itinerary
get customer account
get itinerarypresent itinerary
select segment
present detailed info
update informationavailable flight
Client Account DBMSClient Account DBMS
www.ddss.arch.tue.nl
7M82219
Collaboration Diagram: Change Flt ItineraryCollaboration Diagram: Change Flt Itinerary
Traveler Client Account DBMS
Airline Reservation System
: Booking System
7: update information
2: get customer account3: get itinerary
4: present itinerary
8: available flight
1: change flight itinerary5: select segment
6: present detailed info