Object Messaging ObjectMessaging Objects communicate by sending messages Objectscommunicatebysendingmessages SendingthemessagegetCost()toanAdvert object might use the following syntax object,mightusethefollowingsyntax advertCost=anAdvert.getCost() :Campaign anAdvert : Advert getCost( ) CSE 307 Presentation 11 CSE 307 Presentation 11 22 Resilienceof Design g Resilient System Applicationthat caters Resilient System Real-world requirements Application that caters for these requirements Non Resilient R l ld Application that caters Non- Resilient System CSE 307 Presentation 11 CSE 307 Presentation 11 33 Real-world requirements for these requirements Sequence Diagrams SequenceDiagrams Show an interaction between objects Showaninteractionbetweenobjects arrangedinatimesequence Can be drawn at different levels of detail and Canbedrawnatdifferentlevelsofdetailand tomeetdifferentpurposesatseveralstagesin the development life cycle thedevelopmentlifecycle Typicallyusedtorepresentthedetailedobject i i h f f interactionthatoccursforoneusecaseorfor oneoperation CSE 307 Presentation 11 CSE 307 Presentation 11 44 Sequence Diagrams SequenceDiagrams Vertical dimension shows time Verticaldimension showstime Objectsinvolvedininteractionappear horizontally across the page and represented horizontally acrossthepageandrepresented bylifelines Messages are shown by a solid horizontal Messagesareshownbyasolidhorizontal arrow The execution of an operation is shown by an Theexecutionofanoperationisshownbyan activation CSE 307 Presentation 11 CSE 307 Presentation 11 55 Sequence diagram Sequencediagram :Client :Campaign :Advert Campaign Manager p g getName() listCampaigns() *getCampaign Details() listAdverts() *getAdvert Details() Advert() newAd:Advert addNewAdvert() Activation CSE 307 Presentation 11 CSE 307 Presentation 11 66 Object lifeline Object creation Boundary & Control Classes Boundary&ControlClasses Most use cases imply at least one boundary Mostusecasesimplyatleastoneboundary objectthatmanagesthedialoguebetween the actor and the system in the next theactorandthesystem inthenext sequencediagramitis:AddAdvertUI The control object is :AddAdvert and this Thecontrolobjectis:AddAdvert andthis managestheoverallobjectcommunication. CSE 307 Presentation 11 CSE 307 Presentation 11 77 Boundary&ControlClasses Use Case: Add a new advert to a campaign :AddAdvert :Client :Campaign :Advert Campaign Manager p g :AddAdvertUI showClientCampaigns() selectClient() startInterface() *getClient() g listCampaigns() *getCampaignDetails() selectCampaign() showCampaignAdverts() listAdverts() *getAdvertDetails() listAdverts() createNewAdvert() ddN Ad t() Advert() addNewAdvert() addNewAdvert() newAd:Advert CSE 307 Presentation 11 CSE 307 Presentation 11 88 Object Destruction ObjectDestruction :Campaign :Advert listAdverts() :Campaign :Advert *getAdvertDetails() deleteAdvert() destroy() X Object destruction CSE 307 Presentation 11 CSE 307 Presentation 11 99 Reflexive Messages ReflexiveMessages :Client :Campaign :Advert Campaign Manager p g getName() listCampaigns() *getCampaign Details() checkCampaignBudget() Details() *getCost() getOverheads() g () CSE 307 Presentation 11 CSE 307 Presentation 11 10 10 Focus of Control FocusofControl Indicatestimesduringanactivation whenprocessingistaking g p g g placewithinthatobject Partsofanactivationthatarenotwithinthefocusofcontrol t i d h f l ti i iti representperiodswhen,forexample,anoperationiswaiting forareturnfromanotherobject Maybeshownbyshadingthosepartsoftheactivation y y g p rectanglethatcorrespondtoactiveprocessingbyan operation CSE 307 Presentation 11 CSE 307 Presentation 11 11 11 Focus of Control FocusofControl Campaign Manager :Client :Campaign :Advert getName() Manager listCampaigns() checkCampaignB dget() *getCampaignDetails() checkCampaignBudget() * getCost() tO h d () getOverheads() CSE 307 Presentation 11 CSE 307 Presentation 11 12 12 Return Return A return is a return of control to the object Areturnisareturnofcontroltotheobject thatoriginatedthemessagethatbeganthe activation activation Returnsareshownwithadashedarrow,butit is optional to show them at all since it can be isoptionaltoshowthematallsinceitcanbe assumedthatcontrolisreturnedtothe originating object at the end of the activation originatingobjectattheendoftheactivation CSE 307 Presentation 11 CSE 307 Presentation 11 13 13 Message Types MessageTypes Asynchronousmessage or proceduralcall, shownwithafull y g p , arrowhead,causestheinvokingoperationtosuspend executionuntilthefocusofcontrolhasbeenreturnedtoit A h d ith h d Anasynchronousmessage,drawnwithanopenarrowhead, doesnotcausetheinvokingoperationtohaltexecutionwhile itawaitsareturn CSE 307 Presentation 11 CSE 307 Presentation 11 14 14 FurtherNotation :ClassA Cl B :ClassA :ClassB a Synchronous (blocking) message A ti a b Asynchronous message Construction marks to An active object b {b.sendtime a.sendtime < 3 sec} c < 5 sec. {d receivetime Construction marks to show time constrained interval d {d.receivetime d.sendtime < 1.5 sec} {e.sendtime - d i i Callback Here e is used as e d.receivetime < 6 sec} Time {e e < 6 sec} Here e is used as shorthand for e.sendtime and e represents e.receivetime CSE 307 Presentation 11 CSE 307 Presentation 11 15 15 constraints e.receivetime Message Branching MessageBranching :Campaign checkCampaignBudget() Campaign Manager budget:=checkCampaignBudget() checkCampaignBudget() results in further interaction addCostedAdvert() newAd:Adve [totalCost budget] Advert() [totalCost > budget] Request() rt newRequest:Reque st [totalCost > budget] Request() st CSE 307 Presentation 11 CSE 307 Presentation 11 16 16 HandlingComplexity Complexdiagramscanbesplitintotwoor moresmallerdiagramssuitablyannotated Alternativelyagroupofobjectscanbe representedbyasinglelifeline,andinteraction p y g , amongtheseobjectsisshownonadifferent diagram g CSE 307 Presentation 11 CSE 307 Presentation 11 17 17 HandlingComplexity :AddAdvertUI :AddAdvert These flows are *getClient() Campaign Manager showClientCampaigns() selectClient() listCampaigns() These flows are continued next figure startInterface() *getClient() selectCampaign() showCampaignAdverts() listCampaigns() listAdverts() createNewAdvert() listAdverts() addNewAdvert() addNewAdvert() CSE 307 Presentation 11 CSE 307 Presentation 11 18 18 HandlingComplexity Cli t C i :Advert :Client :Campaign :Advert *getClient() listCampaigns() *getCampaignDetails() These flows are listAdverts() *getAdvertDetails() These flows are continued from the previous figure addNewAdvert() addNewAdvert() Advert() newAd:Advert CSE 307 Presentation 11 CSE 307 Presentation 11 19 19 ObjectGrouping Lifeline representing a set of objects tN () CampaignAdvert s :Client Campaign Manager set of objects getName() listCampaigns() checkCampaignBudget() listCampaigns() CSE 307 Presentation 11 CSE 307 Presentation 11 20 20 Collaboration Diagrams CollaborationDiagrams Holdthesameinformationassequencediagrams Showlinksbetweenobjectsthatparticipateinthe collaboration No time dimension sequence is captured with sequence Notimedimension,sequenceiscapturedwithsequence numbers Sequencenumbersarewritteninanestedstyle(forexample, 3 1 d 3 1 1) t i di t th ti f t l ithi th 3.1and3.1.1)toindicatethenestingofcontrolwithinthe interactionthatisbeingmodelled CSE 307 Presentation 11 CSE 307 Presentation 11 21 21 CollaborationDiagrams Oneallocationof responsibilitiesfor usecase One allocation of responsibilities for use case Add a new advert to a campaign 3.1: showClientCampaigns() 3: selectClient() 4: selectCampaign() 4.1: showCampaignAdverts() 5: createNewAdvert() 5.1: addNewAdvert() 5.1.1: addNewAdvert() :AddAdvertUI :AddAdvert newAd:Adver t 2: startInterface() Campaign 3.1.1: listCampaigns() 5.1.1.1: Advert() 4.1.1: listAdverts() 2: startInterface() 1:*getClient() p g Manager p g () 3.1.1.1: *getCampaignDetails() 4.1.1.1: *getAdvertDetails() :Client :Campaign :Advert CSE 307 Presentation 11 CSE 307 Presentation 11 22 22 MessageLabels Type Example Type Example Simple message. 4: addNewAdvert() Nested call with return value. The return value is placed in the variable name. 3.1.2: name:=getName() Conditional message. This message is only sent if the diti [b l >0] i t [balance >0] 5: debit(amount) condition [balance >0] is true. Synchronization with other threads. 3.1a, 3. 1b / 4:playVideo() Message 4: playVideo() is invoked only once the two concurrent messages 3.1a and g 3.1b are completed. CSE 307 Presentation 11 CSE 307 Presentation 11 23 23 NavigatingLinks checkCampaignBudget() 2 tO h d :Campaign :Client 2: getOverheads 1: *getCost () 1: getCost () The direction in which a :Advert link can be navigated CSE 307 Presentation 11 CSE 307 Presentation 11 24 24 ModelConsistency Theallocationofoperationstoobjectsmustbe consistentwiththeclassdiagramandthe i t t t h th t f th messagesignaturemustmatchthatofthe operation Everysendingobjectmusthavetheobject f f th d ti ti bj t referenceforthedestinationobject Eitheranassociationexistsbetweentheclassesoranotherobject passesthereferencetothesender Messagepathwaysshouldbecarefullyanalysed CSE 307 Presentation 11 CSE 307 Presentation 11 25 25 Model Consistency ModelConsistency Ifbothsequenceandcollaborationdiagramsareprepared q g p p theyshouldbeconsistent Messagesoninteractiondiagramsmustbeconsistentwith th t t h t f th ti i ti bj t thestatechartsfortheparticipatingobjects Implicitstatechangesininteractiondiagramsmustbe consistentwiththoseexplicitlymodelledinstatecharts p y CSE 307 Presentation 11 CSE 307 Presentation 11 26 26