资源预览内容
第1页 / 共54页
第2页 / 共54页
第3页 / 共54页
第4页 / 共54页
第5页 / 共54页
第6页 / 共54页
第7页 / 共54页
第8页 / 共54页
第9页 / 共54页
第10页 / 共54页
亲,该文档总共54页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1.Object-OrientedDesign:BridgingfromAnalysistoImplementationSystemsdesignisthebridgebetweenuserrequirementsandprogrammingthenewsystem.Onestrengthoftheobject-orientedapproachisthatthedesignmodelsareoftenjustextensionsoftherequirementsmodels.Obviously,itismucheasiertoextendanexistingmodelthantocreateentirelynewdesignmodels.OnetenetofAgile,adaptiveapproachestodevelopmentistocreatemodelsonlyiftheyhavemeaningandarenecessary.Thedesignmodelsmaynotbeformalizedintoacomprehensivesetofdocumentsanddiagrams,buttheyarecertainlynecessary.2024/7/25第1页/共53页第一页,共54页。1.1OverviewofObject-OrientedProgramsAnobject-orientedprogramconsistsofasetofprogramobjectsthatcooperatetoaccomplisharesult.Eachprogramobjecthasprogramlogicandanynecessaryattributesencapsulatedintoasingleunit.Theseobjectsworktogethebysendingeachothermessagesandworkinginconcerttosupportthefunctionsofthemainprogram.2024/7/25第2页/共53页第二页,共54页。1.1OverviewofObject-OrientedPrograms2024/7/25第3页/共53页第三页,共54页。1.1OverviewofObject-OrientedProgramsAnobject-orientedsystemconsistsofsetsofcomputingobjects.Eachobjecthasdataandprogramlogicencapsulatedwithinitself.Thisiscalledaninstantiationoftheclassthatis,makinganinstance(anobject)basedonthetemplateprovidedbytheclassdefinition.Eachobjectalsorepresentsastructureofthree-layerarchitecture.2024/7/25第4页/共53页第四页,共54页。1.2Object-OrientedDesignModelsandProcesses2024/7/25第5页/共53页第五页,共54页。1.2Object-OrientedDesignModelsandProcessesThedomainmodelclassdiagramidentifiesalltheclasses,or“things,”thatareimportantintheproblemdomain.Theusecasediagramsidentifiedtheelementarybusinessprocessesthatthesystemneedstosupportinotherwords,allthewaysuserswanttousethesystemtocarryoutprocessinggoals.Theactivitydiagramsandusecasedescriptionsdocumenttheinternalworkflowofeachusecase.2024/7/25第6页/共53页第六页,共54页。1.2Object-OrientedDesignModelsandProcessesAnactivitydiagramshowsthestepsnecessarytocarryoutaparticularusecase.Thesystemsequencediagramsarecloselyrelatedtoactivitydiagrams,exceptthattheyshowthemessagesordatathataresentbackandforthbetweentheuserandthesystemduringthestepsoftheusecase.Finally,statemachinediagramskeeptrackofallstatusconditionrequirementsforoneparticularclass.Theyalsoshowthebusinessrulesthatcontrolthechangingofonestate(statuscondition)toanother.2024/7/25第7页/共53页第七页,共54页。1.2Object-OrientedDesignModelsandProcessesArchitecturaldesignisoneofthefirststepsinsystemsdesign,inasmuchasitprovidesthebigpictureandoverallstructureofthenewsystem.Atthetopoftherightcolumnarecomponentdiagramsanddeploymentdiagrams.wenextseedesignclassdiagrams,orDCDs,whichareanexpansionofthedomainmodelclassdiagram.Thedesignversionofsequencediagramsismuchmoredetailedandisusedtocarryoutmuchofthedetaileddesignactivity.2024/7/25第8页/共53页第八页,共54页。2.Object-OrientedArchitecturalDesignInmostcases,developersbegintothinkabouthowthesystemwillbedeployedandwhattheoverallstructurewilllooklikeduringtheearlystepsofrequirementsgatheringanddocumentation.Softwaresystemsaregenerallydividedintotwotypes:1.single-usersystems2.enterprise-levelsystems.2024/7/25第9页/共53页第九页,共54页。2.Object-OrientedArchitecturalDesignEnterprise-levelsystemsalmostalwaysuseclient/serverarchitectureswithmultiplelayers.Characteristicofenterprise-levelsystems,thedatabaseanddataaccessareonacentralserverbecauseitisasharedresourcethroughouttheorganization.2024/7/25第10页/共53页第十页,共54页。2.Object-OrientedArchitecturalDesign2024/7/25Design IssueClient/Server Network System Internet System (Web)StateStateful” or state-based system e.g., client/server connection is long term.“Stateless systeme.g., client/server connection is not long term and has no inherent memory.Client configuration Screens and forms that are programmed are displayed directly.Domain layer is often on the client or split between client and servermachines.Screens and forms aredisplayed only through abrowser. They must conform to browser technologyServerconfiguration Application or data server directly connects to client tier.Client tier connectsindirectly to the application server through a Web server第11页/共53页第十一页,共54页。2.Object-OrientedArchitecturalDesignTheconceptofstaterelatestothepermanenceoftheconnectionbetweentheclientviewlayerandtheserverdomainlayer.Iftheconnectionispermanent,asinaclient/serversystem,valuesinvariablescanbepassedbackandforthandarerememberedbyeachcomponentinthesystem.Theviewlayerhasdirectaccesstothedatafieldsinthedomainlayer.Inastatelesssystem,suchastheInternet,theclientviewlayerdoesnthaveapermanentconnectiontotheserverdomainlayer.2024/7/25第12页/共53页第十二页,共54页。2.1ComponentDiagramsandArchitecturalDesignThecomponentdiagramidentifiesthelogical,reusable,andtransportable(portable?)systemcomponentsthatdefinethesystemarchitecture.Theessentialelementofacomponentdiagramisthecomponentelementwithitsinterfaces.Acomponentisanexecutablemoduleorprogram,anditconsistsofalltheclassesthatarecompiledintoasingleentity.Therearetwowaystorepresentacomponent:asageneralclassorasaspecificinstance.2024/7/25第13页/共53页第十三页,共54页。2.1ComponentDiagramsandArchitecturalDesign2024/7/25第14页/共53页第十四页,共54页。StereotypingUMLdoeshaverulesforstereotypingasymbolandforextendingthelanguage2024/7/25第15页/共53页第十五页,共54页。Two-LayerArchitecturalDesignofInternetSystems2024/7/25第16页/共53页第十六页,共54页。Two-LayerArchitecturalDesignofInternetSystemsThebusinesslogicinthedomainlayerfrequentlyrelatesonlytodataformattingandtodecidingwhichdatabasetabletoupdate.DuetothestructureofWebservers,theprogram(definedasobject-orientedclasses)thatprocessestheinputformsalsooutputstheHTMLcodethatissentbacktotheclientbrowser.ThebasicideaisthatevenaWeb-basedsystemcanbedevelopedinmultiplelayersoftheviewthatis,theuserinterface,themodel(whichisthebusinesslogicanddatabaseaccess),andthecontroller(whichprovidesalinkbetweentheviewandthemodel).2024/7/25第17页/共53页第十七页,共54页。2.1ComponentDiagramsandArchitecturalDesignItiscriticallyimportantforthesamebackendbusinesslogicanddatabaseaccesstolinkwitheitheruserinterface.Consequently,thedesignteammustspecifythearchitecturaldesigninenoughdetailtoensuretheprogrammersimplementasystemthatcansupportbothuserinterfaces.Eachcomponentisanexecutableprogramandismadeupofclasses.2024/7/25第18页/共53页第十八页,共54页。3.FundamentalPrinciplesofObject-OrientedDetailedDesignTheobjectiveofobject-orienteddetaileddesignistoidentifyandspecifyalltheobjectsthatmustworktogethertocarryouteachusecase.Onemajorresponsibilityofdetaileddesignistoidentifyanddescribeeachsetofobjectswithineachlayerandtoidentifyanddescribetheinteractionsormessagesthataresentbetweentheseobjects.Thefullsequencediagramisusedfordesignandisatypeofinteractiondiagram.Acommunicationdiagramisalsoatypeofinteractiondiagram.2024/7/25第19页/共53页第十九页,共54页。3.FundamentalPrinciplesofObject-OrientedDetailedDesign2024/7/25第20页/共53页第二十页,共54页。3.FundamentalPrinciplesofObject-OrientedDetailedDesign2024/7/25第21页/共53页第二十一页,共54页。3.FundamentalPrinciplesofObject-OrientedDetailedDesignItdescribesthesetofobject-orientedclassesneededforprogramming,navigationbetweentheclasses,attributenamesandproperties,andmethodnamesandproperties.Adesignclassdiagramisasummaryofthefinaldesignthatwasdevelopedbyusingthedetailedsequencediagrams,anditisuseddirectlywhendevelopingtheprogrammingcode.2024/7/25第22页/共53页第二十二页,共54页。Translatemodelintocode.Thesamemodelispresentedindifferentlanguages.2024/7/25第23页/共53页第二十三页,共54页。第24页/共53页第二十四页,共54页。3.1Object-OrientedDesignProcess2024/7/25第25页/共53页第二十五页,共54页。4.DesignClassesandtheDesignClassDiagramThedomainmodelclassdiagramshowsasetofproblemdomainclassesandtheirassociations.Duringanalysis,becauseitisadiscoveryprocess,analystsgenerallydontworrymuchaboutthedetailsoftheattributes.However,inOOP,theattributesofaclassmust?bedeclaredas publicorprivate,andeachattributemustalsobedefinedbyitstype,suchascharacterornumeric.Duringdetaileddesign,itisimportanttoelaborateonthesedetailsaswellastodefinethemethodsandparametersthatarepassedtothemethodsandthereturnvaluesfrommethods.2024/7/25第26页/共53页第二十六页,共54页。4.1DesignClassSymbolsAstereotypeissimplyawaytocategorizeamodelelementasacertaintype.Astereotypeextendsthebasicdefinitionofamodelelementbyindicatingthatithassomespecialcharacteristicwewanttohighlight.EntityControllerBoundary2024/7/25第27页/共53页第二十七页,共54页。Anentityclassisthedesignidentifierforaproblemdomainclass.Itisalsousuallyapersistentclass.Apersistentclassisonewithobjectsthatexistaftertheprogramquits.Aboundaryclass,orviewclass,isspecificallydesignedtoliveonthesystemsautomationboundary.Inadesktopsystem,theseclasseswouldbethewindowsclassesandalltheotherclassesassociatedwiththeuserinterface.2024/7/25第28页/共53页第二十八页,共54页。4.1DesignClassSymbolsAcontrolclassmediatesbetweentheboundaryclassesandtheentityclasses.Inotherwords,itsresponsibilityistocatchthemessagesfromtheboundaryclassobjectsandsendthemtothecorrectentityclassobjects.Itactsasakindofswitchboard,orcontroller,betweentheviewlayerandthedomainlayer.Adataaccessclassisusedtoretrievedatafromandsenddatatoadatabase.Ratherthaninsertdatabaseaccesslogic,includingSQLstatements,intotheentityclassmethods,aseparatelayerofclassestoaccessthedatabaseisoftenincludedinthedesign.2024/7/25第29页/共53页第二十九页,共54页。4.1DesignClassSymbols2024/7/25第30页/共53页第三十页,共54页。4.1DesignClassSymbols2024/7/25第31页/共53页第三十一页,共54页。4.2DesignClassNotationTheformatthatanalystsusetodefineeachattributeincludes:VisibilityWhetherotherobjectscandirectlyaccesstheattribute.(Aplussignindicatesthatanattributeisvisible,orpublic;aminussignindicatesthatitisntvisible,orprivate.)AttributenameType-expression(suchascharacter,string,integer,number,currency,ordate)Initial-value,ifapplicableProperty(withincurlybraces),suchaskey,ifapplicable2024/7/25第32页/共53页第三十二页,共54页。4.2DesignClassNotationRememberthatintheobject-orientedapproach,aclassisatemplatetocreateindividualobjectsorinstances.Thethirdcompartmentcontainsthemethodsignatureinformation.Amethodsignatureshowsalltheinformationneededtoinvoke(orcall)themethod.Itshowstheformatofthemessagethatmustbesent,whichconsistsofthese:MethodvisibilityMethodnameMethodparameterlist(incomingarguments)Returntype-expression(thetypeofthereturnparameterfromthemethod)2024/7/25第33页/共53页第三十三页,共54页。4.2DesignClassNotation2024/7/25第34页/共53页第三十四页,共54页。4.2DesignClassNotationEachofthesubclassesalsohasauniqueattributethatisunderlined,suchasnoOfPhoneSales.Underlinedattributesareclass-levelattributesandhavethesamecharacteristicsasclass-levelmethods.Aclass-levelattributeisastaticvariable,anditcontainsthesamevalueinallinstantiatedobjectsofthesametype.Anitalicizedclassnameindicatesthatitisanabstractclassaclassthatcanneverbeinstantiated.Eachofthethreesubclassesisconsideredaconcreteclassbecauseitcanbeinstantiated;inotherwords,objectscanbecreated.2024/7/25第35页/共53页第三十五页,共54页。4.3DevelopingtheFirst-cut(初步(chb)DesignClassDiagram2024/7/25第36页/共53页第三十六页,共54页。4.3DevelopingtheFirst-CutDesignClassDiagramThefirst-cutdesignclassdiagramisdevelopedbyextendingthedomainmodelclassdiagram.Itrequirestwosteps:(1)elaboratingontheattributeswithtypeandinitialvalueinformationand(2)addingnavigationvisibilityarrows.Asindicatedearlier,object-orienteddesignisusecasedriven.2024/7/25第37页/共53页第三十七页,共54页。4.3DevelopingtheFirst-CutDesignClassDiagram2024/7/25第38页/共53页第三十八页,共54页。AttributeVisibility,NavigationandNavigationVisibilityHereareafewgeneralguidelines:One-to-manyassociationsthatindicateasuperior/subordinaterelationshipareusuallynavigatedfromthesuperiortothesubordinateforexample,fromSaletoSaleItem.Sometimes,theserelationshipsformhierarchiesofnavigationchainsforexample,fromPromotiontoProductItemtoInventoryItem.Mandatoryassociations,inwhichobjectsinoneclasscantexistwithoutobjectsofanotherclass,areusuallynavigatedfromthemoreindependentclasstothedependentclassforexample,fromCustomertoSale.Whenanobjectneedsinformationfromanotherobject,anavigationarrowmightberequired,pointingeithertotheobjectitselfortoitsparentinahierarchy.Navigationarrowsmaybebidirectional.2024/7/25第39页/共53页第三十九页,共54页。4.3DevelopingtheFirst-CutDesignClassDiagram2024/7/25第40页/共53页第四十页,共54页。4.3DevelopingtheFirst-CutDesignClassDiagramThreepointsareimportanttonote.1.First,asdetaileddesignproceedsusecasebyusecase,weneedtoensurethatthesequencediagramssupportandimplementthenavigationthatwasinitiallydefined.2.Second,thenavigationarrowsneedtobeupdatedasdesignprogressestobeconsistentwiththedesigndetails.3.Finally,methodsignatureswillbeaddedtoeachclassbasedonthedesigndecisionsmadewhencreatingthesequencediagramsfortheusecases.2024/7/25第41页/共53页第四十一页,共54页。5.DetailedDesignwithCRCCardsCRCcardsareabrainstormingtechniquethatisquitepopularamongobjectorienteddevelopers.Here,“CRC”isanacronymforClassResponsibilityCollaboration.2024/7/25第42页/共53页第四十二页,共54页。5.DetailedDesignwithCRCCardsForeachusecaseyouneedtodesign,thesestepsaredoneiteratively:1.Selectingausecase2.IdentifyingtheproblemdomainclassthathasresponsibilityforthisusecaseThisobjectwillreceivethefirstmessagefromtheusecasecontroller.Usingthedomainmodelthatwasdevelopedduringanalysis,selectoneclasstotakeresponsibility.Focusonlyontheproblemdomainclasses.Ontheleftsideofthecard,writetheobjectsresponsibility.3.Identifyingotherclassesthatmustcollaboratewiththeprimaryobjectclasstocompletetheusecase2024/7/25第43页/共53页第四十三页,共54页。5.DetailedDesignwithCRCCardsAttheendofthisprocess,youwillhaveasmallsetofCRCcardsthatcollaboratetosupporttheusecase.Anotherhelpfulstepistoincludetheuser-interfaceclasses.Anyotherrequiredutilityclassescanalsobeaddedtothesolution.2024/7/25第44页/共53页第四十四页,共54页。5.DetailedDesignwithCRCCards2024/7/25第45页/共53页第四十五页,共54页。6.FundamentalDetailedDesignPrinciplesCouplingCouplingisaqualitativemeasureofhowcloselytheclassesinadesignclassdiagramarelinked.Asimplewaytothinkaboutcouplingisasthenumberofnavigationarrowsonthedesignclassdiagram.Lowcouplingisusuallybetterforasystemthanhighcoupling.Inotherwords,fewernavigationvisibilityarrowsindicatethatasystemiseasiertounderstandandmaintain.2024/7/25第46页/共53页第四十六页,共54页。6.FundamentalDetailedDesignPrinciplesCohesionButwhatifthatsameobjectalsohadmethodstomakeclassroomassignmentsorassignprofessorstocourses?Thecohesivenessoftheclasswouldbereduced.Classeswithlowcohesionhaveseveralnegativeeffects.First,theyarehardtomaintain.Second,itishardtoreusesuchclasses.2024/7/25第47页/共53页第四十七页,共54页。6.FundamentalDetailedDesignPrinciplesProtectionfromvariationsOneoftheunderlyingprinciplesofgooddesignisprotectionfromvariationstheideathatthepartsofasystemthatareunlikelytochangeshouldbesegregated(orprotected)fromthosethatwillchange.Protectionfromvariationsisaprinciplethatdrivesthemultilayerdesignpattern.2024/7/25第48页/共53页第四十八页,共54页。6.FundamentalDetailedDesignPrinciplesIndirectionIndirectionistheprincipleofdecouplingtwoclassesorothersystemcomponentsbyplacinganintermediateclassbetweenthemtoserveasalink.Inotherwords,instructionsdontgodirectlyfromAtoB;theyaresentthroughCfirst.Orinmessageterminology,dontsendamessagefromAtoB;letAsendthemessagetoCandthenletCforwardittoB.Insertinganintermediateobjectallowsanyvariationsinonesystemtobeisolatedinthatintermediateobject.Indirectionisalsousefulformanycorporatesecuritysystems.2024/7/25第49页/共53页第四十九页,共54页。ObjectResponsibilityOneofthemostfundamentalprinciplesofobject-orienteddevelopmentistheideaofobjectresponsibility;thatis,objectsareresponsibleforcarryingoutthesystemprocessing.Theseresponsibilitiesarecategorizedintwomajorareas:1.KnowingWhatisanobjectexpectedtoknow?2.Doing.Whatisanobjectexpectedtodoortoinitiate?2024/7/25第50页/共53页第五十页,共54页。ObjectResponsibility:Knowning“Knowing”includesanobjectsresponsibilitiesforknowingaboutitsowndataandknowingaboutotherclasseswithwhichitmustcollaboratetocarryoutusecases.Obviously,aclassshouldknowaboutitsowndata,whatattributesexist,andhowtomaintaintheinformationinthoseattributes.Anobjectshouldknowaboutorhavenavigationvisibilitytootherobjectsthatcanprovidetherequiredinformation.2024/7/25第51页/共53页第五十一页,共54页。ObjectResponsibility:Doing“Doing”includesalltheactivitiesanobjectdoestoassistinexecutingausecase.Someofthoseactivitiesincludereceivingandprocessingmessages.Anotheractivityistoinstantiate,orcreate,newobjectsthatmayberequiredforcompletionofausecase.Classesmustcollaboratetocarryoutausecase,andsomeclassesareresponsibleforcoordinatingthecollaboration.2024/7/25第52页/共53页第五十二页,共54页。2024/7/25感谢您的欣赏(xnshng)!第53页/共53页第五十三页,共54页。内容(nirng)总结1. Object-Oriented Design: Bridging from Analysis to Implementation。“Stateless systeme.g.,。Initial-value, if applicable。感谢您的欣赏(xnshng)第五十四页,共54页。
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号