




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Mastering Object-Orientedysis and DesignUse-Caseysis第七章 面象的設(shè)計(jì)方法設(shè)計(jì)用例實(shí)現(xiàn)方案設(shè)計(jì)技術(shù)支撐方案設(shè)計(jì)用戶界面精化設(shè)計(jì)模型RUP中的分析與設(shè)計(jì)流程2面象的設(shè)計(jì)方法基于UML的面為設(shè)計(jì)模型。象設(shè)計(jì)方法將分析模型轉(zhuǎn)換面象:分析模型-頂層架構(gòu)圖,用例與用例圖,領(lǐng)域概念模型。設(shè)計(jì)模型以包圖表示的軟件體系結(jié)構(gòu)圖,以交互圖表示的用例實(shí)現(xiàn)圖,完整、精確的類圖,復(fù)雜對(duì)象的狀態(tài)圖 ,描述流程化處理過(guò)程的活動(dòng)圖3面象的軟件設(shè)計(jì)過(guò)程47.1 設(shè)計(jì)用例實(shí)現(xiàn)方案本節(jié)介紹UML交互圖的語(yǔ)言機(jī)制和用例實(shí)現(xiàn)方案的設(shè)計(jì)方法。UML的交互圖包括順序圖和通信圖,適于用例實(shí)
2、現(xiàn)方案的表示。用例實(shí)現(xiàn)方案的設(shè)計(jì)方法有三個(gè)步驟:提取邊界類、實(shí)體類和控制類;構(gòu)造交互圖;根據(jù)交互圖精化類圖。5Objectives: Use-CaseysisExplahe pure of Use-Caseysis and wherehe lifecycle it isperformedIdentify the classes which perform a use- case flow of eventsDistribute the use-case beior to thoseclasses, identifying responsibilities of the classesDevel
3、op Use-Case Realizationstm instanthe collaborations betnof the identified classes6Use-Caseysis in ContextEarly Elaboration IterationInception Iteration (Optional)Define a Candidate ArchitecturePerform Architectural SynthesisUse-CaseysisDesigneryze Beior(Optional)Refine the ArchitectureDesign the Dat
4、abaseDesign Components7Use-Caseysis OverviewSoftware ArchitectureUse-Case RealizationProject Specific GuidelinesGlossaryUse-CaseysisSupplementary Specificationsysis MUse-Case Mysis Classes8Use-Caseysis StepsSupplement the Use-Case DescriptionFor each Use-Case RealizationFind Classes from Use-Case Be
5、iorDistribute Use-Case BeFor each resultingior to Classesysis classDescribe ResponsibilitiesDescribe Attributes and AssotionsQualifyUnifyCheckpoysis Mechanismsysis Classes s9Use-Caseysis StepsSupplement the Use-Case DescriptionFor each Use-Case RealizationFind Classes from Use-Case BeiorDistribute U
6、se-Case BeFor each resultingior to Classesysis classDescribe ResponsibilitiesDescribe Attributes and AssotionsQualifyUnifyCheckpoysis Mechanismsysis Classes s10Supplement the Use-Case DescriptionThe system displays a list of course offerings.The system retrieves and displays a list of current course
7、 offerings from the course catalog legacy database.11Use-Caseysis StepsSupplement the Use-Case DescriptionFor each Use-Case RealizationFind Classes from Use-Case BeiorDistribute Use-Case BeFor each resultingior to Classesysis classDescribe ResponsibilitiesDescribe Attributes and AssotionsQualifyUnif
8、yCheckpoysis Mechanismsysis Classes s12Review: ClassAn abstractionDescribes a group of objects with common:Properties (attributes)Beior (operations)RelationshipsSemsClaameAttributesOperations13ProfessornameProfessorId : UniqueIdcreate() save() delete() change()6.3.6 建立領(lǐng)域概念模型在用戶需求和相關(guān)的業(yè)務(wù)領(lǐng)域中,有一些全局性的概念對(duì)
9、于理解需求。因此,有必要抽取這些概念,這些概念之間的關(guān)系。UML類圖是表示領(lǐng)域概念模型的機(jī)制。下面首先介紹類圖的語(yǔ)法機(jī)制,然后探討建立領(lǐng)域概念模型的方法。在UML中,用類表示概念,用類圖表示領(lǐng)域概念模型。在需求分析的早期,不需要列舉類的所有屬性和方法。剛開始可以僅標(biāo)識(shí)類名,以后隨著分析、設(shè)計(jì)的不斷推進(jìn)而逐步完善屬性列表和方法列表。14UML類圖UML的類包含三個(gè)部分:類的名稱屬性列表方法列表表示圖元。UML類之間的關(guān)系主要有繼承、關(guān)聯(lián)和依賴。15Review:Use-Case RealizationUse-Case MDesign MUse CaseUse-Case RealizationCo
10、mmunication DiagramsSequence DiagramsUse CaseClass Diagrams16ysis Classes: AStep Toward ExecutablesUse Casesysis ClassesDesign ElementsSource CodeExecUse-Caseysis17Find Classes from Use-Case BeiorThe complete be be distributed toior of a use case has to ysis classes18What Is anysis Class?System info
11、rmationSystem boundarySystem boundaryUse-casebeiorcoordinationSystem information197.1.3 提取邊界類、實(shí)體類和控制類邊界類描述目標(biāo)軟件系統(tǒng)與外部環(huán)境的交互,主要任務(wù):(1)界面控制:包括輸入數(shù)據(jù)的格式及內(nèi)容轉(zhuǎn)換,輸出結(jié)果的呈現(xiàn),軟件運(yùn)行過(guò)程中界面的變化與切換等。(2)外部接口:實(shí)現(xiàn)目標(biāo)軟件系統(tǒng)與外部系統(tǒng)或外部設(shè)備之間的信息交流和互操作。主要關(guān)注系統(tǒng)邊界的通信協(xié)議。目標(biāo)軟件(3)環(huán)境:將目標(biāo)軟件系統(tǒng)與操作系統(tǒng)、數(shù)據(jù)庫(kù)管理系統(tǒng)、應(yīng)用服務(wù)器中間件等環(huán)境軟件進(jìn)行交互的功能與特性封裝于邊界類之中,使目標(biāo)軟件系統(tǒng)的其余部
12、分盡可能地獨(dú)立于環(huán)境軟件。20提取邊界類、實(shí)體類和控制類在 UML 類 圖 中 , 邊 界 類 往 往 附 加 UML 構(gòu) 造 型boundary作為特別標(biāo)識(shí)。例如,“家庭保安系統(tǒng)”中的邊界類有“輸入鍵盤接口類”、“傳感器接口類”、“警報(bào)器接口類”、“接口類”和“顯示面板接口類”。實(shí)體類表示目標(biāo)軟件系統(tǒng)中具有持久意義的信息其操作。實(shí)體類的操作具有“內(nèi)向收斂”特征,僅向目標(biāo)軟件系統(tǒng)的其余部分提供讀、寫信息項(xiàng)內(nèi)容的必要的操作接口,并不涉及業(yè)務(wù)邏輯處理。實(shí)體類的UML構(gòu)造型為entity。例如,“家庭保安系統(tǒng)”中的“異常事件”為實(shí)體類。21提取邊界類、實(shí)體類和控制類控制類作為完成用例任務(wù)的責(zé)任承擔(dān)者
13、,協(xié)調(diào)、控制其他類共同完成用例規(guī)定的功能或行為。對(duì)于比較復(fù)雜的用例,控制類通常并不處理具體的任務(wù)細(xì)節(jié),但是它應(yīng)知道如何分解任務(wù),如何將子任務(wù)分派給適當(dāng)?shù)妮o助類,如何在輔助類之間進(jìn)行消息傳遞和協(xié)調(diào)??刂祁惖腢ML構(gòu)造型為control。例如,“家庭保安系統(tǒng)”中,“用戶命令處理器”和“監(jiān)測(cè)器”均為控制類。22What Is a Boundary Class?ermediates betn theerface andsomething outside the systemSeveral TypesUserSystemDeviceerface classeserface classes erface
14、classesOne boundary class per actor/use-case pairysis class stereotypeEnvironment dependent.23提取邊界類、實(shí)體類和控制類通常情況下,執(zhí)行者與用例之間的一種通信連接對(duì)應(yīng)一個(gè)邊界類。但是,如果兩個(gè)以上的用例與同一執(zhí)行者交互,并且這些交互具有共同的行為、完成相同或類似的任務(wù),就可以考慮用同一邊界類實(shí)現(xiàn)用例與執(zhí)行者之間的交互。這就意味著邊界類的作用范圍可以單個(gè)用例。24The Role of a Boundary ClassActor 1Actor 2Meraction betn the system and
15、 ivironment.25Example: Finding Boundary ClassesOne boundary class per actor/use case pairStudentRegister for CoursesCourse CatalogRegisterForCoursesFormCourseCatalogSystem26Guidelines: Boundary ClassUsererface ClassesConcentrate on what information is presented to the userDo NOT concentrate on the U
16、IsSystem and Deviceerface ClassesConcentrate on what protocols must be definedDo NOT concentrate on how the protocols will be implementedConcentrate on the responsibilities, not thes!27What Is an Entity Class?Key abstractions of the systemysis class stereotypeBusiness-MUse CaseArchitecturalAbstracti
17、onsysisGlossaryEnvironment independent.28提取邊界類、實(shí)體類和控制類實(shí)體類源于領(lǐng)域概念模型。有時(shí)也需要認(rèn)真研讀用例描述,從中發(fā)掘具有持久意義的信息項(xiàng)。如果執(zhí)行者的屬性需要持久保存,也可以建立相應(yīng)于執(zhí)行者的實(shí)體類。假設(shè)一個(gè)實(shí)體類A僅僅被系統(tǒng)中的另一個(gè)類B,并且系統(tǒng)勿需關(guān)心A的行為特征,那么,為了簡(jiǎn)化設(shè)計(jì)模型,應(yīng)將A中信息接作為B的屬性。如果A被系統(tǒng)中的多個(gè)類,或者A具有不容忽略的行為特征,那么應(yīng)將A作為獨(dú)立的實(shí)體類。29The Role of an Entity ClassActor 1Actor 2and manage informationhe sys
18、tem.30Example: Finding Entity ClassesTraditional, filtering nouns approachUnderline noun clauses eventshe use-case flow ofRemove redundant candidatesRemove vague candidatesRemove actors (out of scope)Remove implemenion constructsRemove attributes (save for later)Remove operations31Example: Candidate
19、 Entity ClassesRegister for Courses (Create Schedule)CourseOfferingScheduleStudent32What Is a Control Class?Use-case beior coordinatorMore complex use cases generally require one or more control casesUse Caseysis class stereotypeUse-case dependent. Environment independent.33提取邊界類、實(shí)體類和控制類一個(gè)用例通常對(duì)應(yīng)一個(gè)控制
20、類。封裝一個(gè)或多個(gè)用例所特有的控制行為控制類有效地分離了邊界對(duì)象和實(shí)體對(duì)象,使系統(tǒng)更能承受系統(tǒng)邊界的變更如果不同用例的任務(wù)有較多類似之處,也可以考慮在多個(gè)用例的實(shí)現(xiàn)方案享同一控制類,此種情況應(yīng)審慎對(duì)待,不同用例所需要的控制、協(xié)調(diào)行為往往會(huì)有差異。對(duì)于那些事件流非常簡(jiǎn)單的用例,可以不設(shè)獨(dú)立的控制類,直接在邊界類中設(shè)置控制、協(xié)調(diào)功能,邊界類在實(shí)體類的幫助下完成用例要求的功能及行為。34The Role of a Control ClassActor 1Actor 2Coordinate the use-case beior.35Example: Finding Control ClassesIn
21、general, identify one control class per use case.Asysis continues, a complex use casescontrol class may evolve classo moren oneStudentRegister for CoursesCourse Catalog SystemRegistrationController36Example: Summary:ysis ClassesRegister for CoursesCourse Catalog SystemStudentUse-Case MDesign MCourse
22、CatalogSystemRegisterForCoursesFormStudentScheduleCourseOfferingRegistrationController37Use-Caseysis StepsSupplement the Use-Case DescriptionsFor each Use-Case RealizationFind Classes from Use-Case BeiorDistribute Use-Case BeFor each resultingior to Classesysis classDescribe ResponsibilitiesDescribe
23、 Attributes and AssotionsQualifyUnifyCheckpoysis Mechanismsysis Classes s38Distribute Use-Case Beior to ClassesFor each use-case flow of events:Identifyysis classesAllocate use-case responsibilities to classesysisMdiagramsysis classeractions inUse-Case RealizationeractionCommunication DiagramsSequen
24、ce DiagramsUse CaseClass Diagrams39Guidelines: Allocating Responsibilities to ClassesUseysis class stereotypes as a guideBoundary ClassesBeiortinvolves communication withan actorEntity ClassesBewithiort involves the data encapsulatedhe abstractionControl ClassesBeior specific to a use case or part o
25、f avery important flow of events40The Anatomy of Sequence DiagramsCnt Objectr ObjectMessage:Cnt:rObject LifelineReflexive Message1: PerformResponsibilityEvent Occurrence1.1: PerformAnother ResponsibilityExecution OccurrenceHierarchical Message Numberingreferaction Occurrence41Example: Sequence Diagr
26、am : RegisterForCoursesForm : RegistrationController : CourseCatalogSystem : Course Catalog : Student1: / create schedule( )2: / get course offerings( )Create a new schedule3: / get course offerings(forSemester)4: / get course offerings( )A list of the available course offerings for this semester ar
27、e displayed5: / display course offerings( )A blschedule6: / display blschedule( )is displayed for thestudents to selectofferingsrefSelect OfferingsrefSubmit Schedule42時(shí)序圖示例 : RegisterForCoursesForm : RegistrationController : CourseCatalogSystem : Schedule : Student : Course Catalog : Student1: / cre
28、ate schedule( )2: / get course offerings( )3: / get course offerings(forSemester)新建一個(gè)課程表4: / get course offerings( )5: / display course offerings( )顯示本學(xué)期有效的課程提供的顯示空的課程表讓學(xué)生選擇6: / display blschedule( )課程7: / select 4 prind 2 alternate offerings( )8: / create schedule with offerings9( :) / create with
29、offerings( )10: / add schedule(Schedule)在這一點(diǎn),提交課程表子事件流被執(zhí)行4344UML四種類型的消息簡(jiǎn)單消息(Simple Message)以一種簡(jiǎn)單、抽象的函數(shù)表示對(duì)象之間的信息傳遞,不考慮通信過(guò)程的內(nèi)部細(xì)節(jié)。簡(jiǎn)單消息在UML順序圖中用普通的有向箭頭表示。同步消息(Synchronous Message)消息源發(fā)出消息后必須等待消息處理過(guò)程完畢并返回處理結(jié)果后,消息源才可繼續(xù)執(zhí)行后續(xù)操作。前面所述的自調(diào)用消息應(yīng)該是同步的。同步消息的表示圖元與簡(jiǎn)單消息相同,這表明UML在缺省情形下認(rèn)為簡(jiǎn)單消息即為同步消息。異步消息(Asynchronous Messa
30、ge) 表示,消息源發(fā)出消息后不必等待消息處理過(guò)程的返回,即可繼續(xù)執(zhí)行自己的后續(xù)操作。異步消息主要用于描述實(shí)時(shí)系統(tǒng)中的并為。異步消息在UML順序圖中用一種特別的單向箭頭表示。返回消息(Return message) 表示前面發(fā)送的消息的處理過(guò)程完結(jié)之后的返回結(jié)果。返回消息應(yīng)該是同步的。在許多情況下,可以隱藏返回消息,但也可顯式標(biāo)出返回消息以示強(qiáng)調(diào)。返回消息用虛線有向箭頭表示一個(gè)對(duì)象可以通過(guò)發(fā)送標(biāo)準(zhǔn)消息“new”來(lái)創(chuàng)建另一個(gè)對(duì)象。當(dāng)一個(gè)對(duì)象被刪除或自我刪除時(shí),該對(duì)象的生命線上的相應(yīng)時(shí)間點(diǎn)應(yīng)該用叉號(hào)(對(duì)象生命線終結(jié)符)標(biāo)識(shí)。457.1.2 通信圖-協(xié)作圖通信圖用于描述相互合作的對(duì)象間的交互關(guān)系和關(guān)
31、系。雖然順序圖和通信圖都用來(lái)描述對(duì)象間的交互關(guān)系,但它們的側(cè)重點(diǎn)不一樣。順序圖強(qiáng)調(diào)消息交互的時(shí)間序,通信圖則強(qiáng)調(diào)交互對(duì)象間的靜態(tài)關(guān)系。從外,通信圖并不采用單獨(dú)的維度來(lái)表示時(shí)間推移,因此,通信圖中的對(duì)象可以在二維平面中占位。對(duì)象之間的用于表之上,消示消息傳遞通道,消息標(biāo)示于息的箭頭指明消息的傳遞方向。在通信圖中,消息的描述內(nèi)容包含名稱、參數(shù)、返回值以 及序列號(hào),返回值和序列號(hào)是可選的。46The Anatomy of Communication DiagramsCnt ObjectLinkr Object:Cnt:rPerformResponsibilityMessage47協(xié)作圖雖然協(xié)作圖不強(qiáng)
32、調(diào)消息傳遞的時(shí)間序,但借助于序列號(hào)可以表達(dá)時(shí)間序,序列號(hào)較大的消息發(fā)生較晚。消息序列號(hào)可以采用線性,但采用適當(dāng)?shù)亩嗉?jí)晰。會(huì)使消息之間的結(jié)構(gòu)關(guān)系更清如果一個(gè)對(duì)象在消息的交互過(guò)程中被創(chuàng)建,則可在對(duì)象名稱之后標(biāo)以new。類似地,如果一個(gè)對(duì)象在交互期間被刪除,則可在對(duì)象名稱之后標(biāo)以destroy。48典型的協(xié)作圖例“1.1 msg2”表明msg2是“對(duì)象1”為了處理 “1. msg1”而發(fā)送的第一條消息“1.2 msg4”是“對(duì)象1”為了處理“1. msg1”而發(fā)送的第二條消息“1.1.1 msg3”表明 msg3是“對(duì)象2”為了處理“1.1 msg2”而發(fā)送的第一條消息,依此類推。49等價(jià)表示50E
33、xample: Communication Diagram5: / display course offerings( )6: / display blschedule( )rse offerings( )2: / get course offerrse offerings(forSemester)1: / c: Student51 : RegisterForCoursesFormreate schedule(): Course Catalog4: / get cou : CourseCatalogSystemings( )3: / get cou : RegistrationControll
34、erOneeraction Diagram Is Not Good EnoughBasic FlowAlternate Flow 1Alternate Flow 2Alternate Flow 3AF3AF1AF2Alternate Flow 4Alternate Flow 5Alternate Flow n52Communication Diagrams vs. Sequence Diagrams53Communication DiagramsSequence DiagramsShow relationships in addition toeractionsBetter for visua
35、lizing patterns of collaborationBetter for visualizing all of the effects on a given objectEasier to use for brainstorming sessShow the explicit sequence of messagesBetter for visualizing overall flowBetter for real-time specifications and for complex scenariosUse-Caseysis StepsSupplement the Use-Ca
36、se DescriptionsFor each Use-Case RealizationFind Classes from Use-Case BeiorDistribute Use-Case BeFor each resultingior to Classesysis classDescribe ResponsibilitiesDescribe Attributes and AssotionsQualifyUnifyCheckpoysis Mechanismsysis Classes s54Describe ResponsibilitiesWhat are responsibilities?H
37、owfind them?eraction Diagram:Cnt:r/ PerformResponsibilityClass Diagramr/ PerformResponsibility557.1.4 構(gòu)造交互圖在標(biāo)識(shí)邊界類、實(shí)體類和控制類之后,接下來(lái)的任務(wù)是,將分析模型中的用例描述轉(zhuǎn)化成 UML交互圖,以交互圖作為用例的精確實(shí)現(xiàn)方案。用例描述中已包含事件流說(shuō)明。事件流中的事件應(yīng)直接對(duì)應(yīng)于交互圖中的消息,而事件間的先后關(guān)系體現(xiàn)為交互圖中的時(shí)序,對(duì)消息的響應(yīng)則責(zé)。消息接收者的職這種職責(zé)在后續(xù)的設(shè)計(jì)活動(dòng)中將被確立為類的方法。56構(gòu)造交互圖對(duì)于比較復(fù)雜的用例,僅僅依靠控制類、邊界類和實(shí)體類會(huì)使單個(gè)
38、控制類過(guò)于龐大、復(fù)雜,它既承擔(dān)控制、協(xié)調(diào)的任務(wù),又承擔(dān)復(fù)雜的計(jì)算任務(wù)。在設(shè)計(jì)復(fù)雜用例的實(shí)施方案時(shí),應(yīng)考慮為控制類設(shè)置一些獨(dú)立的輔助類,讓控制類將一些任務(wù)委托給輔助類完成。如,在 “家庭保安系統(tǒng)”類圖中,“系統(tǒng)配置管理器”和“日志管理器”就是這種意義上的輔助類。57構(gòu)造交互圖UML順序圖的橫向排列次序用例的主動(dòng)執(zhí)行者用戶界面的邊界類控制類實(shí)體類和輔助類外部接口和環(huán)境層的邊界類目標(biāo)軟件系統(tǒng)的邊界之外的執(zhí)行者按此布局,在順序圖中不應(yīng)該出現(xiàn)穿越控制類生命線的消息,即,主動(dòng)執(zhí)行者向界面類發(fā)出命令,界面類將命令進(jìn)行適當(dāng)轉(zhuǎn)換后傳送至控制類,控制類通過(guò)消息請(qǐng)求輔助類、實(shí)體類的幫助,協(xié)調(diào)、控制它們共同完成來(lái)命令
39、。動(dòng)執(zhí)行者的58構(gòu)造交互圖控制類或輔助類可以向右側(cè)的邊界類發(fā)送消息,將信息或外部處理請(qǐng)求由邊界類傳向外部系統(tǒng)(執(zhí)行者)。在用例描述中,許多用例除主事件流外,往往還包含備選事件流,以說(shuō)明在某些特殊或者異常情況下的事件和響應(yīng)動(dòng)作序列。為易于理解,在設(shè)計(jì)模型中應(yīng)該用分離的UML交互圖分別表示事件流和每個(gè)備選事件流。按照上述布局規(guī)則繪制的典型的順序圖如圖10.4所示59典型布局規(guī)則下的順序圖60構(gòu)造協(xié)作圖順序圖能夠非常直觀地表達(dá)事件(消息)的時(shí)序,它比協(xié)作圖地用于描述用例的實(shí)現(xiàn)方案。但是,當(dāng)需要強(qiáng)調(diào)類之間的聯(lián)系或連接時(shí),就需要繪制協(xié)作圖。協(xié)作圖的布局規(guī)則控制類位于中心主動(dòng)執(zhí)行者和作為用戶界面的邊界類位
40、于左上方作為外部接口和環(huán)境層的邊界類位于右上方輔助類和實(shí)體類分別位于控制類的左下、右下方。按照此布局規(guī)則繪制的典型的協(xié)作圖如圖10.5所示。61典型布局規(guī)則下的協(xié)作圖62例家庭保安系統(tǒng)在“家庭保安系統(tǒng)”中,用例“傳感器監(jiān)測(cè)”和“命令處理”的實(shí)現(xiàn)方案分別見(jiàn)圖 10.6和圖10.7。為簡(jiǎn)潔,圖10.6和圖10.7未表示這兩個(gè)用例中的日志功能,圖10.7也未考慮配置命令的處理。63圖10.6 “傳感器監(jiān)測(cè)”用例的順序圖64圖10.7 “命令處理”用例的順序圖65Example: View of Participating Classes (VOPC) Class Diagram66 CourseCa
41、talogSystem/ get course offerings() Schedule/ commit()/ select alternate()/ remove offering()/ level()/ cancel()/ get cost()/ delete()/ submit()/ save()/ anys()/ create with offerings()/ update with new selections() RegisterForCoursesForm/ display course offerings()/ display blschedule()/ create sch
42、edule() RegistrationController/ get course offerings()/ get current schedule()/ delete current schedule()/ submit schedule()/ is registration open?()/ save schedule()/ create schedule with offerings()/ update schedule with new selections() Student/ get tuition()/ add schedule()/ get schedule()/ dele
43、te schedule()/ has pre-requisites()維持一致性類中多余的職責(zé)類中分離的職責(zé)只有一個(gè)職責(zé)的類沒(méi)有職責(zé)的類更好的行為分配方式與許多其他類有交互作用的類67Use-Caseysis StepsSupplement the Use-Case DescriptionsFor each Use-Case RealizationFind Classes from Use-Case BeiorDistribute Use-Case BeFor each resultingior to Classesysis classDescribe ResponsibilitiesDesc
44、ribe Attributes and AssotionsQualifyUnifyCheckpoysis Mechanismsysis Classes s68Review: What Is an Attribute?ClaameAttribute : Type = InitValue Attribute : Type = InitValue Attribute : Type = InitValueattributeInysis, do not spend time on attribute signatures.69 CourseOfferingnumber : String = 100 st
45、artTime : Time endTime : Timedays : Enum numStudents : 確定屬性類的特征類要保留的信息不能成為類的名詞值很重要的信息某個(gè)對(duì)象獨(dú)有的信息沒(méi)有行為的信息70Review: What Is an Assotion?The semrelationship betn two ormore classifierst specifies connectionsamong their instanA structural relationship, specifyingt objectsof one thing are connected to objec
46、ts of another71 Course Student Schedule關(guān)聯(lián)關(guān)系表示兩個(gè)類的對(duì)象之間存在著用于消息傳遞的穩(wěn)定通道。如,在課程管理系統(tǒng)中,“學(xué)生”類、“老師”類與“課程設(shè)置”類之間存在關(guān)聯(lián)關(guān)系,因?yàn)椤罢n程設(shè)置”與選課學(xué)生和授課老師有關(guān),學(xué)生和老師都需要查詢課程設(shè)置的有關(guān)信息。兩個(gè)類的對(duì)象之間往往存在著數(shù)量對(duì)應(yīng)關(guān)系,這種關(guān)系是業(yè)務(wù)規(guī)則的具體表現(xiàn)。因此,當(dāng)分析和設(shè)計(jì)推進(jìn)到一定階段之后,應(yīng)該在、和關(guān)聯(lián)關(guān)系的表示邊上明確標(biāo)示。如,圖6.2表示每個(gè)“課程設(shè)置”對(duì)象應(yīng)不少于10個(gè)、不多于 50個(gè)選課學(xué)生。每個(gè)學(xué)生在一個(gè)學(xué)期中選課的課程不少于4門、不多于8門。72Finding Rela
47、tionshipsCommunication DiagramPerformResponsibility:Cnt:rLinkCntrClass DiagramCnt0.*0.*rPerformResponsibility()AssotionRelationship for every link!73Review: What Is Aggregation?A spel form of assotiont ms awhole-part relationship betn anaggregate (the whole) and its partsWhole/aggregatePart174 Sched
48、ule0.*0.2 CourseOffering0.* Student和關(guān)系UML將普通關(guān)系分為關(guān)系:一個(gè)部件對(duì)象可同時(shí)參與多個(gè)整體對(duì)象。關(guān)系:限定一個(gè)部件對(duì)象在任意時(shí)刻只能參與一個(gè)整體類的對(duì)象,部件類對(duì)象與整體類對(duì)象共存亡。75Assotion or Aggregation?If two objects are tightly bound by a whole-partrelationshipThe relationship is an aggregation.10.2,4If two objects are usually considered as independent, althou
49、gh they are often linkedThe relationship is an assotion.When in doubt, use asso76tion.CarDoor10.2,4DoorCar依賴關(guān)系依賴關(guān)系依賴類B的對(duì)象需要向被依賴類A的對(duì)象傳遞消息;被依賴類A可作為依賴類B操作的形參類型。依賴關(guān)系表示臨時(shí)性的消息傳遞通道,操作完成通道;關(guān)聯(lián)關(guān)系及強(qiáng)化形態(tài)表示消息傳遞通道在整個(gè)對(duì)象的生命周期中穩(wěn)定存在。77依賴關(guān)系如,假設(shè) “訂單”包中的類僅依賴于“數(shù)據(jù)庫(kù)接口”包中的類(接口),并不需要在它們之間建立關(guān)聯(lián)關(guān)系,因?yàn)?,?duì)數(shù)據(jù)庫(kù)的和操作僅在訂單處理類的函數(shù)體中的局部進(jìn)行。依賴
50、關(guān)系是關(guān)聯(lián)關(guān)系的弱化,它表示被依賴的類的變化會(huì)影響到依賴類。依賴的強(qiáng)化是關(guān)聯(lián),關(guān)聯(lián)的強(qiáng)化是聚合,聚合的強(qiáng)化是。78What Are Roles?The “face”t a class playsheassotionRole NamePrerequisites79 Course CourseOfferingInstructor Professor DepartmentDepartment HeadWhat Does Multiplicity Mean?Multiplicity answers two questions:Is the assotion mandatory or optional?
51、What is the minimum andum number ofinstant can be linked to one instance?CourseOfferingCourse0.*10.*Prerequisites0.380Example: Multiple AssotionsprimaryCoursesalternateCoursesTwo roles : validTwo operation : invalidMultiple assotions must reflect multiple roles.81 Scheduleadd student to CourseOfferi
52、ngremove student rom Schedule CourseOfferingExample: VOPC: Finding Relationships0.1currentSchedule82 Student Schedule0.1primaryCourses CourseOffering10.*0.*0.4 RegisterForCoursesForm RegistrationController11建立領(lǐng)域概念模型為建立UML類圖表示的領(lǐng)域概念模型,首先要標(biāo)識(shí)關(guān)鍵概念。關(guān)鍵概念業(yè)務(wù)需求描述、用例說(shuō)明;業(yè)務(wù)領(lǐng)域中的相關(guān)規(guī)范、標(biāo)準(zhǔn)、術(shù)語(yǔ)定義;反映業(yè)務(wù)領(lǐng)域知識(shí)的既往經(jīng)驗(yàn)?!凹彝ケ0蚕到y(tǒng)”
53、的領(lǐng)域概念模型如圖6.18所示。83“家庭保安系統(tǒng)”的領(lǐng)域概念模型84家庭保安系統(tǒng)”的領(lǐng)域概念模型圖6.18中新引入了“用戶命令處理器”、“系統(tǒng)配置管理器”、“監(jiān)測(cè)器”、“異常事件”和“日志管理器”五個(gè)新類。“用戶命令處理器”接收來(lái)自用戶的操作命令,并將命令處理結(jié)果反饋至顯示面板?!跋到y(tǒng)配置管理器”保存系統(tǒng)的配置信息,協(xié)助“用戶命令處理器”完成用戶對(duì)系統(tǒng)配置信息修改,還要負(fù)責(zé)向系統(tǒng)中的其他類提供配置信息的查詢服務(wù)?!氨O(jiān)測(cè)器”負(fù)責(zé)接收傳感器的數(shù)據(jù),根據(jù)系統(tǒng)配置信息判別異常狀況,在異常發(fā)生時(shí)生成“異常事件”對(duì)象、觸發(fā)警報(bào)器并拔話?!叭罩竟芾砥鳌彪娤蛳到y(tǒng)中的其他類提供日志的和查詢服務(wù),日志信息應(yīng)包括
54、用戶命令及處理結(jié)果、配置更改的歷史,異常狀況的歷史等。85Use-Caseysis StepsSupplement the Use-Case DescriptionsFor each Use-Case RealizationFind Classes from Use-Case BeiorDistribute Use-Case BeFor each resultingior to Classesysis classDescribe ResponsibilitiesDescribe Attributes and AssotionsQualifyUnifyCheckpoysis Mechanisms
55、ysis Classes s86Review: Why Useysis Mechanisms?ysis mechanisms are used duringysiduce thecomplexity of designers wiysis and to improve its consistency by providingshornd represenion for complex beior.Oh no! I found a group of classes has persistent data. How am Itsuped to design these things if Idon
56、t even know what database we are going to be using?t is why weersistenceysis mechanism. We dontknow enough yet, so we canbookmark it and come back to it later.87Describingysis MechanismsCollect allysis mechanisms in a listDraw a map of the c ysis mechanismsnt classes to theIdentify characteristics of the mechanismsysis88Example: Describingysis Mechanismsysis class toysis mechanism map89ysis Classysis Mechanism(s)StudentPersistency, SecuritySchedulePersistency,
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025如何高效管理電子合同
- 2025廣東石油交易所入市交易合同協(xié)議書
- 動(dòng)畫制作合同范本
- 大樓租賃合同書
- 2025全球技術(shù)服務(wù)合同
- 2025臨時(shí)辦公空間租賃合同范本
- 房屋空白定購(gòu)協(xié)議書
- 桉樹買賣協(xié)議書版本
- 2025年03月浙江臺(tái)州市椒江區(qū)事業(yè)單位公開招聘工作人員49人筆試歷年典型考題(歷年真題考點(diǎn))解題思路附帶答案詳解
- 2025年03月河北邯鄲市市直事業(yè)單位(統(tǒng)一公開招聘)工作人員318名筆試歷年典型考題(歷年真題考點(diǎn))解題思路附帶答案詳解
- 籃球智慧樹知到期末考試答案章節(jié)答案2024年浙江大學(xué)
- 《歸去來(lái)兮辭(并序)》課件
- 臨床生物化學(xué)檢驗(yàn)練習(xí)題庫(kù)(含答案)
- X射線衍射儀(XRD)行業(yè)市場(chǎng)現(xiàn)狀供需分析及市場(chǎng)深度研究發(fā)展前景及規(guī)劃投資研究報(bào)告
- 2024年強(qiáng)基計(jì)劃解讀 課件-2024屆高三下學(xué)期主題班會(huì)
- 認(rèn)識(shí)常用電子元件圖解
- DB21-T 3413-2021地下工程自防護(hù)混凝土結(jié)構(gòu)耐久性技術(shù)規(guī)程
- 學(xué)校食品安全管理
- 團(tuán)隊(duì)溝通與協(xié)作培訓(xùn)
- 美的社會(huì)責(zé)任報(bào)告2023
- 2021年4月自考00908網(wǎng)絡(luò)營(yíng)銷與策劃試題及答案含評(píng)分參考
評(píng)論
0/150
提交評(píng)論