Object-OrientedSoftwareEngineering:UsingUML,Patterns,andJava:SolutionstoExercises Bridgesandaircrafthavesafetyrequirementsassociatedwiththem.Thisleadstoaconservativeapproachto developmentincludingtheuseofmaturetechnologiesandwelldefinedprocesses Bridgesandaircraftaresometimesdeliveredlatetoo C2004Prenticehall November14.2003 Object-OrientedSoftwareEngineering:UsingUML,Patterns,andJava:SolutionstoExercises C2004Prenticehall November14.2003 Object-OrientedSoftwareEngineering:UsingUML,Patterns,andJava:SolutionstoExercises 2.ModelingwithUML:Solutions 2-1ConsideranATMsystemIdentifyatleastthreedifferentactorsthatinteractwiththissystem Anactorisanyentity(userorsystem)thatinteractswiththesystemofinterest.ForanATM,thisincludes Bankcustomer ATMMaintainer CentralbankComputer Thief Thelastactorisoftenreferredtoasa"misactor"intheliterature,becauseitisanactorthatinteractswiththesystem butshouldnt 2-2CanthesystemunderconsiderationberepresentedasanactorJustifyyouranswer: Thesystemunderconsiderationisnotexternaltothesystemandshouldntberepresentedasanactor.Thereareafew cases,however,whenrepresentingthesystemasanactormayclarifytheusecasemodel.Theseincludesituations wherethesysteminitiatesusescases,forexample,astimepasses(CheckforOutdatedArticles,SendDaily Newsletter) 2-3Whatisthedifferencebetweenascenarioandausecase?Whendoyouuseeachconstruct Ascenarioisanactualsequenceofinteractions(i.e,aninstance)describingonespecificsituation;ausecaseisa generalsequenceofinteractions(i.e,aclass)describingallpossiblescenariosassociatedwithasituation.Scenarios areusedasexamplesandforclarifyingdetailswiththeclient.Usecasesareusedascompletedescriptionstospecify ausertaskorasetofrelatedsystemfeatures 2-4Drawausecasediagrarnforaticketdistributorforatrainsystem.Thesystemincludestwoactors:atraveler, whopurchasesdifferenttypesoftickets,andacentralcomputersystem,whichmaintain.sareferencedatabase forthetarif.Usecasesshouldinclude:BuyOneWayTicket,BuyWeeklyCard,BuyMonth/yCara,UpdateTariff Alsoincludethefollowingexceptionalcases:Time-Out(i.e.,travelertooktoolongtoinserttherightamount), TransactionAborted(i.e,travelerselectedthecancelbuttonwithoutcompletingthetransaction), Dibutoroutofchange,anddistributorOutofPaper BuyOneWwayTicket Time-Out BuyweeklyCard VistributorException Transactionaborted Traveler BuyMonthlyCard Distributoroutofchan CentralComputersystem Updatetariff DistributoroutofPaper Figure2-1ExamplesolutiontoExercise2 C2004Prenticehall November14.2003 Object-OrientedSoftwareEngineering:UsingUML,Patterns,andJava:SolutionstoExercises Thisquestionscanhaveseveralcorrectanswers,Figure2-1beingapossibleanswer.Thefollowingelementsshould bepresent Therelationshipbetweenanactorandausecaseisacommunicationrelationship(undirectedsolidline) Therelationshipbetweenexceptionalusecasesandcommonusecasesisanrelationship Theexceptionalusecasesdescribedintheexerciseonlyapplytotheusecasesinvokedbythetraveler Thefollowingelementsshouldbepresentina""answer: Allexceptionsapplytoalltravelerusecases.Insteadofdrawing3x4relationshipsbetweentheseusecases,an abstractusecasefromwhichtheexceptionalusecaseinheritcanbeused,thusreducingthenumberof relationshipsto3atthecostofintroducing4generalizationrelationships Thestudentcanintroduceexceptionalusecasesnotspecifiedintheexercisethatapplytothe CentralComputersystemusecases 2-5WritetheflowofeventsandspecifyallfieldsfortheusecaseUpdateTariffthatyoudrewinExercise2-4.Do notforgettospecifyanyrelationships Figure2-2depictsapossiblesolutionforthisexercise secasename UpdateTariff ParticipatingactorInitiatedbyCentralComputerSystem Flowofevents I.TheCentlComputerSystemactivatesthe"UpdateTariff'functionoftheticketdistributorsavailable onthenetwork 2.Theticketdistributordisablesthetravelerinterfaceandpostsasignindicatin thattheticketdistributorisundermaintenance 3.Theticketdistributorwaitsforthenewdatabasefromthe CentralComputerSystem 4.Afterwaitingaminutefortheticketdistributorstoreachawaitingstate,theCentralcomputerSystem broadcaststhenewdatabase 5.Theticketdistributorsystcmrcccivcsthencwdatabascoftariff.Uponcomplctc theticketdistributorsendsanacknowledgementtotheCentralComputerSystem. 6.Afteracknowledgmenttheticketdistributorenablesthetravelerinterfaceand canissueticketsatthenewtariff 7.TheCentralComputerSystemchecksifallticketdistributorshaveacknowledgedthenewdatabase.If not,theCentralComputerSysteminvokestheCheckNonRespondingDistributorsusecase Entrycondition TheticketdistributorisconnectedtoanetworkreachablebytheCentralcomputerSystem Exitcondition Theticketdistributorcanissueticketsunderthenewtariff.or Theticketdistributorisdisabledanddisplaysasigndenotingthatitisundermaintenance Q uality Theticketdistributorstaysofflineatmost2minutesandisconsideredout-of-orderotherwise requirements Figure2-2ApossiblesolutionfortheUpdateTariffusecase C2004Prenticehall November14.2003 Object-OrientedSoftwareEngineering:UsingUML,Patterns,andJava:SolutionstoExercises 2-6Drawaclassdiagramrepresentingabookdefinedbythefollowingstatement:"Abookiscomposedofa numberofparts,whichinturnarecomposedofanumberofchapters.Chaptersarecomposedofsections. ocusonlyonclassesandrelationshuip Book Part Chapter Sect Figure2-3ExamplesolutionforExercise2-6 Thisexercisechecksthestudent'sunderstandingofbasicaspectsofclassdiagrams,including Classesarerepresentedwithrectangles Theattributeandoperationscompartmentcanbeomitted gregationrelationshipsarerepresentedwithdiamonds Classnamesstartwithacapitalletterandaresingular 2-7AddmuliplicitylotheclassdiagramyouproducedinExercise2-6 SeeFigure2-3.Aggregationdoesnotimplymultiplicity,thusthe1..*multiplicityisnecessary objectdiagramyoudrawisconsistentwiththeclassdiagramofExerciseZotingStarted).Makesurethalthe 2-8Druwanobjectdiagramrepresentingtheirstpartofthisbook(i.e,PartL,Ge oose:Book gettingStarted:Part introduction:Chapter uml:Chapter communication:Chapter 1.1:S 2.1:Sect 3.1:Secti 1.2:Section 2.2:Section 3.2:Section 13:Section 2.3:Section 3.3:Section 1.4:Section 2.4:Section 3.4:Section 1.5:Section Section 3.5:Section 1.6:Sectio refs:Section 3.6:Section refs:section refs:Section Figure2-4ExamplesolutionforExercise2-8 Thisexercisechecksthestudent'sunderstandingofbasicaspectsofobjectdiagrams,including C2004Prenticehall November14.2003 Object-OrientedSoftwareEngineering:UsingUML,Patterns,andJava:SolutionstoExercises Objectsarerepresentedwithrectanglesandunderlinedlabels Theclassofanobjectisincludedinthelabeloftheobject(e.g,um1:ChapterisofclassChapter) Linksarerepresentedwithsolidlines 2-9ExtendtheclassdiagramofExercise2-6toincludethefollowingattributes abookincludesapublisher,publicationdate,andanISBN apartincludesatitleandanumber achapterincludesatitle,anumber,andanabstract asectionincludesatitleandanumber Book Part Chapter Section publisher:Person title:String title:String title:String oublicationdate:date number:Integer number:Integer number:Integer ISBN:Integer[4] abstract:String 1 Figure2-5ExamplesolutionforExercise2-9 ThisexerciseschecksthestudentsknowledgeofattributesandtheirrepresentationinUML(page45) 2-10ConsidertheclassdiagramofExercise2-9.NotethatthePart,Chapter,andSectionclassesallincludeatitle andanumberattribute.Addanabstractclassandageneralizationrelationshiptofactoroutthesetwo attributesintotheabstractclass Numbdcomponent title:stril number:Integer abstract:String Book Part Chapter Section pubSher.Person abstract:String publicationDate:Date ISBN:Integer[4] 1 1 Figure2-6ExamplcsolutionforExcrcisc2-10 Thisexercisechecksthestudent'sknowledgeofabstractclassesandinheritance 2-11Drawaclassdiagramrepresentingtherelationshipbetweenparentsandchildren.Takeintoaccountthata personcanhavebothaparentandachild.Annotateassociationswithrolesandmultiplicities Figure2-7depictsacanonicalsolution.Thisexerciseismeanttoemphasizethedifferencebetweenarelationship,a role,andaclass.Intheabovesentence,parentandchildareroleswhilepersonistheclassunderconsideration.This resultsinaclassdiagramwithasingleclassandasingleassociationwithbothendstotheclass C2004Prenticehall November14.2003 Object-OrientedSoftwareEngineering:USingUML,Patterns,andJava:SolutionstoExercises Acommonmodelingmistakebynovicesistodrawtwoclasses,onefortheparentandoneforthechild child Person parent2 Figure2-7ExamplesolutionforExercise2-11 yourclassdiagram.Yourclassdiagramshouldbeasdetailedaspossibenau 2-12Druwaclassdiagramforbibliographicreferences.Usethereferences AppendixC,Bibliography,lolest Thedomainofbibliographicreferencesisrichandcomplex.Consequently,studentsshoulddeepenedtheir understandingofthedomainbeforetheyattempttodrawaclassdiagram(similartotherequirementsanalysisofa system).Figure2-8depictsanincompletesamplesolutionthatcouldbeacceptedassufficientfromaninstructor.The lassdiagramshouldminimallyincludethefollowingconcepts Anabstractclasspub/on(orBibliographicReference) AmanytomanyrelationshipbetweenAuthorandPublicatio Atleastthreeormoreconcreteclassesrefiningpublication Atleastoneaggregationrelationship(e.g,betweenJournalandArticleorProceedingsand ConferencePaper).BothendsoftheaggregationshouldalsobesubclassesofPublication Author Publication title:String publicationDate:Date Book Journal bisher:Person volume:Integer publicationDate:Date numberInteger ISBN:Integer[4 1 Compendium Proceedings Article editors:Person[ conferencelocation irstPage:Integer conferenceDate:Date lastPage:Integer 1 CompendiumChapter Conferencepaper chapte irstPage:Integer astPage:Integ Figure2-8ExamplesolutionforExercise2-12. 2-13DrawasequencediagramforthewarehouseOnFirescenarioofFigure2-15.Includetheobjectsbob,alice john,FRIEND,andinstancesofotherclassesyoumayneedDrawonlythefirstfivemessagesends C2004Prenticehall November14.2003 Object-OrientedSoftwareEngineering:UsingUML,Patterns,andJava:SolutionstoExercises Thisexercisechecksthestudentsknowledgeofsequencediagramswhenusinginstances.Thisexercisecanhave severalcorrectanswers.InadditiontotheUMLrulesonsequencediagrams,allcorrectsequencediagramsforthis exerciseshouldincludeoneormoreactorsontheleftofthediagramwhoinitiatethescenario,oneormoreobjectsin thecenterofthediagramwhichrepresentthesystem,andadispatcheractorontherightofthediagramwhois notifiedoftheemergency.Allactorsandobjectsshouldbeinstances.Figure2-9depictsapossibleanswer. FRIEND b alice John reportEmergencyo newEmergencyFormo :Emergency orm specifyIncidento requestResource(fireTrug commit notifyDispatcherOI Figure2-9ExamplesolutionforExercise2-13 2-14DrawasequencediagramfortheReportIncidentusecaseofFigure2-14.Drawonlythefirstfivemessage sends.MakesureitisconsistentwiththesequencediagramofExercise2-13 Thisexerciseteststhestudentsknowledgeofsequencediagramwhenusingclasses.Likethepreviousexercise,this exercisecanhaveseveralcorrectsolutionsacorrectsolutionshouldincludeafieldofficeractoronthelefta Dispatcheractorontheright,andoneormoreclassesinthemiddlerepresentingtheFRIENDsystem.Theanswerto thisexerciseshouldbeconsistentwiththeanswertothepreviousexercise,inthesensethatallclassandoperation namesshouldbethesameFigure2-10depictsapossibleanswer FRIEND Fieldofficer Dispatcher newEmergencyFormO reportEmergencyo 凵EmergencyForm specifyIncidento *rdquestResourceo commit notifyDipatchero Figure2-10ExamplesolutionforExercise2-14 2-15Considertheprocessoforderingapizzaoverthephone.Drawanactivitydiagramrepresentingeachstep theprocess,fromthemomentyoupickupthephonetothepointwhereyoustarteatingthepizza.Donot representanyexceptionsIncludeactivitiesthatothersneedtoperform Figure2-llisanexamplesolutionforthisexercise.Thefollowingelementsshouldbepresentinthesolution Activitynamesshouldbeverbphrasesindicatingwhattheinitiatingactorisattemptingtoaccomplish.Roles shouldbeindicatedwithswimlanes C2004Prenticehall November14.2003