軟件工程概論課件面向?qū)ο?9classdesign_第1頁
軟件工程概論課件面向?qū)ο?9classdesign_第2頁
軟件工程概論課件面向?qū)ο?9classdesign_第3頁
軟件工程概論課件面向?qū)ο?9classdesign_第4頁
軟件工程概論課件面向?qū)ο?9classdesign_第5頁
免費預(yù)覽已結(jié)束,剩余74頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、MasteringObject-Oriented with UML 2.0ClassMasteringObject-Oriented with UML 2.0Classysisand Objectives:ClassDefinetheeofClassDesignObjectives:ClassDefinetheeofClassDesignhelifecycleitisIdentifyadditionalclassesandneededtosupportionofchosenarchitecturalIdentifyand objects of syzeetransitionse-control

2、ledRefinerelationships,operations,and 2ClassDesignin3Iteration(Optional)Define a CandidateClassDesignin3Iteration(Optional)Define a CandidateyzeRefineDesignthe ClassDesignDesignUse-Case ysisUse-Case ProjectSpecific DesignysisDesignClassDesignDesignUse-Case ysisUse-Case ProjectSpecific DesignysisDesi

3、gn4類之間的耦合程度(從高到低)(1)類之間的耦合程度(從高到低)(1)5ClassDesignCreateInitialDesign ClassDesignCreateInitialDesign DefineOperations Define MethodsDefineDefine Attributes DefineDependenciesDefineernalDefineGeneralizations Resolve Use-CasesHandle Nonfunctional RequirementsinGenerals6ClassDesignCreateInitialClassDesi

4、gnCreateInitialDesignClasses Define OperationsDefineDefineDefineDefineDefineernalDefineResolveUse-CasesHandleNon-FunctionalRequirementsins7ClassDesignClassClassDesignClassApplicabledesign8HowManyClassesAreMany,simple classesteachEncapsulatesHowManyClassesAreMany,simple classesteachEncapsulateslessof

5、theoverallsystem Ismore Iseasier toAfew,complex classesteach Encapsulatesa large portion oftheIs less likely to be reusable IsmoredifficulttoimplementAclassshould haveasinglewell-focused Aclassshould doonething 9tStrategiesforDesigningBoundaryerface(UI)boundary Whaterface developmenttoolswillbeExter

6、nalerfaceboundary UsuallyaStrategiesforDesigningBoundaryerface(UI)boundary Whaterface developmenttoolswillbeExternalerfaceboundary UsuallyaStrategiesforDesigningEntityEntityobjects areoftenpassive and1StrategiesforDesigningEntityEntityobjects areoftenpassive and1-+ -StrategiesforDesigningControlppen

7、sStrategiesforDesigningControlppenstoControlAretheyreally Shouldtheybe HowdoyouChange Distributionand ion ClassDesignCreateInitialDesignClasses Define OperationsDefineClassDesignCreateInitialDesignClasses Define OperationsDefineDefineDefineDefineDefineernalDefineResolveUse-CasesHandleNon-FunctionalR

8、equirementsinsWhereDoYouFindMessagesdisplayed eraction: : tOtherManagerion dependent NeedforclassWhereDoYouFindMessagesdisplayed eraction: : tOtherManagerion dependent NeedforclassNeedtotestfor: 1:performResponsibility(): : 1: /Perform NameandDescribetheNameandDescribetheCreateappropriateoperationDe

9、fineoperationoperationName(directionparameter :class,.): Directionisin(default),out or Provideshortdescription,includingmeaning of all parametersOperationVisibilityisusedtoOperationVisibilityisusedtoenforceMaybepublic,protected,orHowIsVisibilityThefollowingsymbolsareusedtoHowIsVisibilityThefollowing

10、symbolsareusedtospecify export control:-Public ac ProtectedacPrivatesss-+#-privateOperation+publicOPeration#protecteOperationDeterminesnumberofinstan ofInstance:oneinstanceforDeterminesnumberofinstan ofInstance:oneinstanceforeachclassClassifier:oneinstanceforallclassClassifierscopeisdenotedbyunderli

11、ningthe attribute/operation name-+classifierScopeOp+copeOple:-nextAvailID +addSchedule(inle:-nextAvailID +addSchedule(intheSchedule:Schedule,inforSemester:+getSchedule(inforSemester:Semester):+hasPrerequisites(inforCourseOffering:CourseOffering): # passed (in theCourseOffering : CourseOffering) :+ge

12、tNextAvailID() le:Define1+getCourseOfferings():+getCurrentSchedule(inforStudent:Student,inforSemester:Semester):+new(le:Define1+getCourseOfferings():+getCurrentSchedule(inforStudent:Student,inforSemester:Semester):+new(inforStudentID:+getStudent(inanID):+ +getTuition():+addSchedule(inaSchedule:+getS

13、chedule(inforSemester:Semester):+deleteSchedule(inforSemester:+hasPrerequisites(inforCourseOffering:CourseOffering): # hasPassed ( in aCourseOffering : CourseOffering) :+getNextAvailID() +getStudentID()+getName():+getAddress():ClassDesignCreateInitialClassDesignCreateInitialDesignClasses Define Oper

14、ationsDefineDefineDefineDefineDefineernalDefineResolveUse-CasesHandleNon-FunctionalRequirementsinsDefineWhatisa Describesoperation DefineWhatisa Describesoperation Thingstol Otherobjectsand operations tobe Howattributesandparametersaretobe implemented and usedHowrelationshipsaretobeimplemented and C

15、lassDesignCreateInitialDesignClassDesignCreateInitialDesignClasses Define OperationsDefineDefineDefineDefineDefineernalDefineResolveUse-CasesHandleNon-FunctionalRequirementsinsDefineeDesignhowanobjectss eDefineeDesignhowanobjectss eaffectsDevelop emachines tothis可WhatisaeAdirectedgraph ofes(nodes) c

16、onnectedWhatisaeAdirectedgraph ofes(nodes) connectedtransitions(directed a Describesthe lifehistoryofareactiveGuardSSEvent(args)guard SeSePseudoInitialeInitialeTheeenteredwhenSobjectisMandatory,canonlyhave one initial sPseudoInitialeInitialeTheeenteredwhenSobjectisMandatory,canonlyhave one initial s

17、Dynamic evaluation of subsequentguardconditionsFinaleIndicatestheofdFinaleSOptional,mayhavemore n oneIdentifyandDefinetheSignificant,dynamicumnumberofstudentspercourseofferingIdentifyandDefinetheSignificant,dynamicumnumberofstudentspercourseofferingisnumStudents = Existenceand non-existenceofcertain

18、LinktoProfessor LinktoProfessor doesnt existIdentifytheLook attheerfaceEvents:IdentifytheLook attheerfaceEvents:+IdentifytheForeach e,determine whateventswhates,includingguard conditions,when IdentifytheForeach e,determine whateventswhates,includingguard conditions,when Transitionsdescribewha to the

19、 receipt of an eventppens in +AddExecutedwhenSseisOngoingSAddExecutedwhenSseisOngoingSSExecutedwhenseisle:eaddStudent/numStudents=numStudents+/numStudents=removeStudentnumStudents0/numStudents=numStudents-le:eaddStudent/numStudents=numStudents+/numStudents=removeStudentnumStudents0/numStudents=numSt

20、udents-do/SendcancellationnumStudents=10closenumStudents=3removeStudentnumStudents0/numStudents=numStudents-closeRegistrationnumStudents=3mStudents+le:eMachinewithNestedesande/numStudents= do/SendcancellationeclosenumStudentsle:eMachinewithNestedesande/numStudents= do/SendcancellationeclosenumStuden

21、ts=3HremoveStudentnumStudents0/numStudents=numStudents-closeRegistrationnumStudents=3do/GenerateclassClassDesignCreateInitialClassDesignCreateInitialDesignClasses Define OperationsDefineDefineDefineDefineDefineernalDefineResolveUse-CasesHandleNon-FunctionalRequirementsinsAttributeSpecifyname, type,a

22、nd optionaldefault attributeNameAttributeSpecifyname, type,and optionaldefault attributeName:Type=Follownamingconventionsofimplemen language and projectSpecifyPublic: + Private:Protected:DerivedWhatisaDerivedWhatisaderivedAnattributewhosevaluemaybecalculated based on the value of other attribute(s)W

23、hendoyouuseWhenthereisnotenough timetore-calculate the value every time it is neededWhenyoumusttrade-offruntimeperformance versus memory required為了提高運行效率,有為了提高運行效率,有時需要在對象的生命同期中保存經(jīng)計算生成的一些中間結(jié)果,以免此時可以引入派生屬性作為類的私有屬性。但是,在業(yè)務(wù)邏輯處理過程中,要特別注意生屬性值容易失。le:Defineerface+-semester:+1 +-studentID-dateOfBirth:number:

24、String=startTime:endTime:le:Defineerface+-semester:+1 +-studentID-dateOfBirth:number:String=startTime:endTime:day:派生屬性在其名稱前加-/numStudents=ClassDesignCreateInitialClassDesignCreateInitialDesignClasses Define OperationsDefineDefineDefineDefineDefineernalDefineResolveUse-CasesHandleNon-FunctionalRequir

25、ementsinsDefineWhatIsaArelationship ntwo eDeterminewherestructuralrelationshipsare DefineWhatIsaArelationship ntwo eDeterminewherestructuralrelationshipsare NOT requiredCrDependenciesvs.tionsarestructural Dependenciesarenon- structural relationshipsIn order for objects to “know eachother”theymustbev

26、isibleLocalvariable CParameterGlobal FieldDependenciesvs.tionsarestructural Dependenciesarenon- structural relationshipsIn order for objects to “know eachother”theymustbevisibleLocalvariable CParameterGlobal Field為了在對象obj1與對象obj2之間實現(xiàn)消息傳遞,面:為了在對象obj1與對象obj2之間實現(xiàn)消息傳遞,面:(3)局部對象。在obj1的某項操作的函數(shù)體中創(chuàng)建或獲前三種類型的

27、連接具有暫時性,obj1與obj2之間的連接僅在 型的部分整體關(guān)系,則用UML關(guān)系表示。否則,件對象”的部分整體關(guān)系,則用UML的普通聚合關(guān)系表示。如果以上兩種假設(shè)均不成立, 則原連接關(guān)系精化成UML中普通的關(guān)聯(lián)關(guān)系LocalVariableTheop1()operationcontainsLocalVariableTheop1()operationcontainsalocal variable of type ClassB+op1(ParameterTheClassBinstanceispassedtoParameterTheClassBinstanceispassedtothe Class

28、A instance+op1(inaParam:ClassBGlobalTheitistilityinstanceisGlobalTheitistilityinstanceis+utilityOp(+op1(IdentifyingDependencies:Permanentrelationships tion(fieldIdentifyingDependencies:Permanentrelationships tion(fieldTransientrelationships MultipleobjectssharethesamePassinstanceasaparameter(paramet

29、er Makeinstanceamanagedglobal (global Multipleobjectsdontsharethesameinstance(local Define+getCourseOfferings(inforSemester:Semester):+/submitschedule+/saveschedule+/createschedulewithofferingsGlobal+/getcourseofferings-semester:+submit+/save() # anyFieldDefine+getCourseOfferings(inforSemester:Semes

30、ter):+/submitschedule+/saveschedule+/createschedulewithofferingsGlobal+/getcourseofferings-semester:+submit+/save() # anyFields?+/createwith+1+StudentIDnumber:String=startTime:endTime:day:+addSchedule(inaSchedule:Schedule+getSchedule(inforSemester:Semester):+hasPrerequisites(inforCourseOffering:Cour

31、seOffering): # passed ( in aCourseOffering : CourseOffering ) :+addStudent(inaStudentSchedule:+removeStudent(inaStudentSchedule:+new+setDataParameterClassDesignCreateInitialClassDesignCreateInitialDesignClasses Define OperationsDefineDefineDefineDefineDefineernalDefineResolveUse-CasesHandleNon-Funct

32、ionalRequirementsinsDefineeRefineremaining ThingstolookforDefineeRefineremaining Thingstolookfortionvs.Aggregationvs.Attributevs.WhatIsA form of aggregation with strong ownershipandcoincidentlifetimesTheparts cannotsurviveWhatIsA form of aggregation with strong ownershipandcoincidentlifetimesThepart

33、s cannotsurvivetheAggregation:Sharedvs.Non-Shared MultiplicityNon-sharedMultiplicity=Multiplicity=11Bydefinition, ition isnon-shared Aggregation:Sharedvs.Non-Shared MultiplicityNon-sharedMultiplicity=Multiplicity=11Bydefinition, ition isnon-shared AggregationorLifetimesofClass1and AggregationorLifet

34、imesofClass1and le:111le:111Review:WhatIstitsibletonavigateantingclasstousingReview:WhatIstitsibletonavigateantingclasstousingtheNavigability:WhichDirectionsAreReallyeractionEvenwhenbothdirectionsseemrequired, one may workNavigabilityinonedirectionisNumberofNavigability:WhichDirectionsAreReallyeract

35、ionEvenwhenbothdirectionsseemrequired, one may workNavigabilityinonedirectionisNumberofofoneclassis ?+關(guān)系的方向性是非常明顯的。對UML的關(guān)依賴、聚合和要仔細(xì)推敲雙向關(guān)聯(lián)的必要性,聯(lián)單向化關(guān)系的方向性是非常明顯的。對UML的關(guān)依賴、聚合和要仔細(xì)推敲雙向關(guān)聯(lián)的必要性,聯(lián)單向化如果允許修改被重用的類,那么可以將被重用的類與當(dāng)前否則,可以采用“委托”的辦法,在擬重用的類和被重用重重tionA class is “attached”toan-+ / ected+/ markectedpropertie

36、sofa Has one instanceperlink+/ markascancelled0.* tionA class is “attached”toan-+ / ected+/ markectedpropertiesofa Has one instanceperlink+/ markascancelled0.* + -+/ isenrolledin?+/ markasenrolledin+/ markascommitted關(guān)聯(lián)關(guān)系本身具有的屬性和操作, 將關(guān)聯(lián)關(guān)系本身具有的屬性和操作, 將這些屬性或操作置放于參與關(guān)聯(lián)的兩個類之任何一個均會破壞設(shè)計模型的自然性。此時需le:tionClas

37、s+ + -+/isenrolledin?+/markasenrolledin+/markascommittedDesigns+ 1le:tionClass+ + -+/isenrolledin?+/markasenrolledin+/markascommittedDesigns+ 11-+/isenrolledin?+/markasenrolledin+/markascommittedWhatIsaParameterizedClassAclasstdefinesotherOftenusedforcontainerWhatIsaParameterizedClassAclasstdefineso

38、therOftenusedforcontainerSomecommon container Sets,lists,dictionaries,stacks,InstantiatingaParameterizedInstantiatingaParameterizedle:InstantiatingaParameterized11le:InstantiatingaParameterized11ClassDesignCreateInitialClassDesignCreateInitialDesignClasses Define OperationsDefineDefineDefineDefineDe

39、fineernalDefineResolveUse-CasesHandleNon-FunctionalRequirementsinsReview:StructureDiagramWithStructuredBehaviorServiceAssemblyReview:StructureDiagramWithStructuredBehaviorServiceAssemblyRelayDelegationClassDesignCreateInitialDesignClassDesignCreateInitialDesignClasses Define OperationsDefineDefineDe

40、fineDefineDefineernalDefineResolveUse-CasesHandleNon-FunctionalRequirementsinsReview:One class shares thestructureand/or behavior of one or more classes“Isakindof” ysis,Review:One class shares thestructureand/or behavior of one or more classes“Isakindof” ysis, +erest +withdraw+ementAbstractandConcre

41、teAbstractclassesveanyConcreteclassescanhaveAbstractAbstractTherearenodirectofAbstractandConcreteAbstractclassesveanyConcreteclassescanhaveAbstractAbstractTherearenodirectof+communicate+communicateAllobjectsareeitherlionsor+communicateMultipleInheritance:Name clashes on attributesoroperationsRepeate

42、dMultipleInheritance:Name clashes on attributesoroperationsRepeated +getColor+getColor+getColor+getColorGeneralization sEndoftheinheritanceGeneralization sEndoftheinheritance Inheritancetreemay be SubclassesmutuallyDoesntsupportmultiple Subclassesare notmutually Supportsmultiple le:GeneralizationsnotsupportedBRealeEndofinheritancele:GeneralizationsnotsupportedBRealeEndofinheritancele:Generalizations le:Generalizations Generalizationvs.Generalizationandaggregationareoften GeneralizationrepresentsGeneralizationvs.Generalizationandaggregationareoften Generalizationrepresentsan“isa”or“kind-of”

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論