Object Interaction - Sequence Diagrams: Based On Chapter 9 Bennett, Mcrobb and Farmer
Object Interaction - Sequence Diagrams: Based On Chapter 9 Bennett, Mcrobb and Farmer
Sequence Diagrams
Based on Chapter 9
Bennett, McRobb and Farmer
Object Oriented Systems Analysis
and Design Using UML
4th Edition, McGraw Hill, 2010
© 2010 Bennett, McRobb and Farmer 1
In This Lecture You Will Learn:
• how to develop object interaction from use
cases;
• how to model object interaction using an
interaction sequence diagram;
• how to cross-check between interaction
diagrams and a class diagram.
currentadvertCost = anAdvert.getCost()
:Campaign anAdvert:Advert
getCost
Frame label :
CampaignManager :Client :Campaign :Advert
getName
Sequence listAdverts
diagram loop [For all campaign’s adverts]
is enclosed in a getAdvertDetails
frame
addNewAdvert
Advert
newAd:Advert
sd Interaction Name
:LifelineA :LifelineB State on lifeline showing
Synchronous pre-condition
(blocking)
message
Receive messaged
Active Event Occurrence
(msg.recieveEvent)
Send message
Event Occurrence msg a start of
(msg.sendEvent) Execution Occurrence
Execution Occurrence
end of
Execution Occurrence
Message reply
showing return of
control
:AddAdvertUI
startInterface
selectClient showClientCampaigns listCampaigns
selectCampaign
showCampaignAdverts
listAdverts
loop [For all campaign’s adverts]
getAdvertDetails
createNewAdvert
addNewAdvert addNewAdvert
Advert
newAd:Advert
sd Delete advert
:Campaign :Advert
listAdverts
loop getAdvertDetails
deleteAdvert
delete
Object destruction
:
CampaignManager :Client :Campaign :Advert
getName
listCampaigns
loop [For all client’s campaigns]
getCampaignDetails
checkCampaignBudget
loop [For all campaign’s adverts]
getCost Reflexive
message
getOverheads
checkCampaignBudget
loop [For all campaign’s adverts]
getCost
getOverheads
Reply with the return-
value shown
budget =
checkCampaignBudget
: campaign[i] advert[j]
CampaignManager :Client
:Campaign :Advert
getName
checkCampaignBudget
getOverheads
: campaign[i] advert[j]
CampaignManager :Client
:Campaign :Advert
getName
listCampaigns
loop (1, *) [i<=campaign.count ]
getCampaignDetails
checkCampaignBudget
loop (1, *) [j<=advert.count ]
getCost
Interaction Operator
with parameters getOverheads
:
:Client :Campaign :Advert
CampaignManager
getName
listCampaigns ref
ref
Get campaign budget
addCostedAdvert
alt [totalCost <= budget]
Advert newAd:Advert
alt interaction operator
shows branching
[else]
Request newRequest:Request
Two interaction operands,
one for each alternative
:
CampaignManager :Client :Campaign :Advert
getName
listCampaigns ref
ref
listCampaigns
loop [For all client’s campaigns]
getCampaignDetails
: :Campaign :Advert
CampaignManager
checkCampaignBudget
getOverheads
:ClientCampaigns
: :AddAdvert ref ClientCampaignAds
CampaignManager
loop [For all clients]
getClient
:AddAdvertUI
startInterface
selectClient showClientCampaigns listCampaigns
createNewAdvert
addNewAdvert addNewAdvert
getClient
listCampaigns
referenced in the
Add a new advert to listAdverts
a campaign sequence loop [For all campaign’s adverts]
diagram getAdvertDetails
addNewAdvert
Advert newAd:Advert
getCost
ref
Calculate costs getCost
ref
alt [Within budget] Identify under spend
Within budget
Within budget
authorize
[else] [else]
Budget spent Budget spent
stopExpenditure
t = now Asynchronous
Time sign
alE message with
constraint {0..1
4} duration
using constraint
construction
marks
signalF
{t..t + 28}
Callback
signal Duration
X d = du
ration observation
{d..d*3}
critical Critical Region imposes a constraint on the operand that none of its event occurrences on the lifelines
in the region can be interleaved.
ignore Ignore indicates the message types, specified as parameters, that should be ignored in the interaction.
consider Consider states which messages should be consider in the interaction. This is equivalent to stating that
all others should be ignored.
assert Assertion states that the sequence of messaging in the operand is the only valid continuation.
loop Loop is used to indicate an operand that is repeated a number times until the interaction constraint for
the loop is no longer true.
32
© 2010 Bennett, McRobb and Farmer
Guidelines for Sequence Diagrams
1. Decide at what level you are modelling
the interaction.
2. Identify the main elements involved in
the interaction.
3. Consider the alternative scenarios that
may be needed.
4. Identify the main elements involved in
the interaction.