StudentAnswersChapter05.docx
- 文档编号:20190402
- 上传时间:2023-04-25
- 格式:DOCX
- 页数:7
- 大小:66.52KB
StudentAnswersChapter05.docx
《StudentAnswersChapter05.docx》由会员分享,可在线阅读,更多相关《StudentAnswersChapter05.docx(7页珍藏版)》请在冰豆网上搜索。
StudentAnswersChapter05
SuggestedanswerforExercise5.1
Therestaurantobjectisclearlynotaboundaryobject,butitmightappeartosharesomecharacteristicsofbothcontrolandentityobjects.
Asitisresponsibleformaintainingdata,itmightbearguedthattheentitystereotypewasappropriate.Thisstereotypeisnormallyusedfordatainthesystemthatrepresentsasingleexternalentity,however.Therestaurantobjectdoesnotrepresentanentityinthissense,however,butinsteadmakesotherentitiesavailableinthesystem.Theentitystereotypeisprobablynotappropriatefortherestaurantobject,therefore.
Thereisacontrolaspecttotherestaurantobject,asitiscontrollingaccesstotheentitydataheldbythesystem.Thisismoreaquestionofbeinga`gatekeeper'tosomesystemresourcesthancontrollinganumberofinteractions,asthebookingsystemobjectdoes,anditisprobablyclearernottorepresentbothbythesamestereotype.
Itthereforeappearsthatnoneoftheanalysisclassstereotypesstraightforwardlyappliestotherestaurantobject,andithasbeenleftinFigure5.4asaplainobject.
SuggestedanswerforExercise5.2
Thedateattributeinthebookingsystemclassrepresentsthedateforwhichbookinginformationiscurrentlybeingdisplayedbythesystem.Thedateattributeinthe`current'bookingsshouldbethesameasthis,therefore,otherwisethesystemwillbedisplayingbookingsforthewrongdate.Thiscanbespecifiedbyaconstraintonthe`current'associationasshownbelow.
SuggestedanswerforExercise5.3
Onthefaceofit,thisproposalmightseemtobeattractiveonthegroundsofremovingredundancy,followingtheguidelinethatdatashouldnotbestoredinmorethanoneplace.However,removingthedateattributefromthebookingsystemobjectwouldcreateproblemsinthesituationwheretherearenobookingsyetrecordedforadatethesystemisaskedtodisplay.Inthiscase,thesystemwouldhavenorecordofwhatdatewascurrentlybeingdisplayed.Ifawalk-inbookingwasthencreated,forexample,itwouldbedifficulttoworkoutthedaterequiredforthenewbookingobject.
Thissuggeststhatstoringthedateinbothclassesisnotinfactredundant,asthetwooccurrencesoftheattributehavedifferentsemantics,onereferringtothedatebeingdisplayedbythesystem,andtheothertothedateofanindividualbooking.Incaseslikethis,careneedstobetakenbefore`optimizing'oneoftheattributesaway.
SuggestedanswerforExercise5.4
Producingarealizationforthisscenarioinvolvesdecidingwhichobjectisresponsiblefordetectingthatthedateisinvalid.Areasonableguidelinetoadopthereistovalidateuser-entereddataassoonaspossible.Thiswouldmeanthatthebookingsystemobjectshouldberesponsiblefordetectingerrors,andsoarealizationmightbeasfollows.
Therestaurantandbookingobjectshavebeenleftonthisdiagramtoemphasizethattheydonotreceiveanymessagesinthecourseofthisinteraction.Itisnotnecessaryatthislevelofdetailtoattempttospecifyhowthesystemreportstheerrortotheuserandrequestsreentryofthedate.Wecansimplyassumethatwhentheuserreentersthedateanewsystemmessagewillbegenerated,andeithertheinteractionaboveortheoneinFigure5.5willtakeplaceagain.
SuggestedanswerforExercise5.5
Thecompletesequencediagramisshownbelow.
SuggestedanswerforExercise5.6
Thesequencediagramfor`Recordwalk-in'isshownbelow.Apartfromchangingtheactor,classandoperationnamesthroughouttorefertowalk-ins,themostsignificantchangeisthatacustomerobjectdoesnotneedtobelocated.Detailsreferringtocustomershavethereforebeenremovedfromthediagram.
SuggestedanswerforExercise5.7
Arealizationforthecasewherethecustomerisalreadyknowntothesystemisshowninthediagrambelow.AsinFigure5.5,therestaurantobjectretrievesdatafromcustomerobjectstocomparewiththenameandphonenumberoftherequestedcustomer.Assumingthatamatchisfound,acustomerobjectisreturnedtothecaller.
Inthecasewherenomatchingcustomerisfound,anewinstanceiscreatedandareferencetoitisreturnedtothecaller,asshownbelow.
SuggestedanswerforExercise5.8
Apossiblesequencediagramfortabletransferisshownbelow.Therequiredtableisfirstselected,asshowninFigures5.9and5.11.Thenthetableobjectcorrespondingtothenumberofthenewtableisretrievedfromtherestaurantobject,asinFigure5.8.Finally,thetableallocatedtotheselectedbookingisupdated,andthedisplayrefreshed.
Analternativedesignmightpassthetablenumbertotheselectedbooking,whichwouldthenhavetoretrievetherequiredtableobjectfromtherestaurantitself.Thisdesignisslightlymore`decentralized'thantheoneabove,butontheotherhandintroducesacirculardependencybetweenthebookingandrestaurantclasses.Thedesignshownaboveisthereforeprobablypreferable.
SuggestedanswerforExercise5.9
ThediagramsbelowshowtheclassesfromFigure5.13withtypeinformationaddedtoattributesandoperations.TheadditionsarestrictlybasedonwhatisstatedinthevariousrealizationsgiveninChapter5,anddonotattempttodefinefinalsignaturesfortheoperations.Thiswillbeconsideredlaterwhenimplementingeachclass.
Wheredetailedparametershavenotyetbeendefined,typessuchasBookingIdandBookingDetailshavebeenusedasplaceholders.TheOCLcollectiontypeSet(T)hasbeenusedtoindicatethattheRestaurant.getBookingsoperationreturnsingeneralmorethanonebookingsobject.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- StudentAnswersChapter05