軟件工程理論與實(shí)踐課件:第6章 對(duì)象_第1頁(yè)
軟件工程理論與實(shí)踐課件:第6章 對(duì)象_第2頁(yè)
軟件工程理論與實(shí)踐課件:第6章 對(duì)象_第3頁(yè)
軟件工程理論與實(shí)踐課件:第6章 對(duì)象_第4頁(yè)
軟件工程理論與實(shí)踐課件:第6章 對(duì)象_第5頁(yè)
已閱讀5頁(yè),還剩139頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、SOFTWARE ENGINEERING 軟件工程,Considering Objects 對(duì)象,6.1 What is OO (Object orientation)什么是面向?qū)ο?,Object orientation is an approach to software development that organizes both the problem and its solution as a collection of discrete objects; both data structure and behavior are included in the representa

2、tion. 面向?qū)ο笫且环N軟件開(kāi)發(fā)方法,它由問(wèn)題和問(wèn)題的解決方法組成不連續(xù)對(duì)象的集合;數(shù)據(jù)結(jié)構(gòu)和行為都包含在表示中。,Object 的特點(diǎn),以數(shù)據(jù)為中心; 對(duì)象是主動(dòng)的; 屬性和操作封裝,信息是隱蔽的; 對(duì)象獨(dú)立處理自身的數(shù)據(jù),并通過(guò)消息傳遞進(jìn)行通信,具有并行的性質(zhì); 高模塊獨(dú)立性,對(duì)象是OO軟件的基本模塊,低耦合,高內(nèi)聚; 對(duì)象具有唯一識(shí)別的功能,行為比較豐富; 對(duì)象必須參與一個(gè)或多個(gè)對(duì)象類。,Class 類,定義 具有相同結(jié)構(gòu)、操作,并遵守相同約束規(guī)則的對(duì)象聚合成一組,這組對(duì)象集合稱為對(duì)象類,簡(jiǎn)稱類。 類層次(Hierarchy) 子類、派生類 父類、基類、超類 類實(shí)例(Instance)

3、 由某個(gè)特定類所描述的一個(gè)具體對(duì)象。 如類抽象“中國(guó)人”的一個(gè)實(shí)例“王志東”,消息就是某個(gè)操作的規(guī)格說(shuō)明,其組成: 接收消息的對(duì)象 消息名(消息選擇符) 零個(gè)、一個(gè)或多個(gè)變?cè)?例如:對(duì)于類Circle的一個(gè)實(shí)例MyCircle,如果使其以綠 色在屏幕上顯示,MyCircle . Show ( GREEN ); 方法(操作、服務(wù)) 對(duì)象所能執(zhí)行的操作,即類中所定義的服務(wù)。它是對(duì)操作算法和響應(yīng)消息辦法的描述。 在類Circle中給出成員函數(shù)Show (int color)的定義。 屬性是類中所定義的數(shù)據(jù),是實(shí)體性質(zhì)的抽象 類實(shí)例都有其特有的屬性值,如類Circle定義的圓心、半徑和顏色。,消息、方

4、法與屬性,The History of OT 對(duì)象技術(shù)的歷史,We can recognize an OO representation by its seven characteristics(我們可以從它的7個(gè)特征來(lái) 認(rèn)識(shí)OO): 1、Identity 一致性 2、Abstraction 抽 象 3、Classification 分 類 4、Encapsulation 封 裝 5、Inheritance 繼 承 6、Polymorphism 多態(tài)性 7、Persistence 連續(xù)性,特征一、Identity(一致性),Identity refers to the fact that th

5、e data are organized into discrete, distinguishable entities called objects. A single object has states and behaviors associated with it. Every object has a name (also called a reference or handle). 一致性涉及將數(shù)據(jù)組成離散的、可辨識(shí)的稱為 對(duì)象的實(shí)體。單個(gè)對(duì)象有與之相關(guān)的狀態(tài)和行為。 每一個(gè)對(duì)象都有一個(gè)名稱(也叫引用或句柄)。,特征二、 Abstraction (抽象),Abstraction i

6、s essential for building any system, whether OO or not. 構(gòu)建任何系統(tǒng)時(shí),無(wú)論是否使用OO, 抽象都是必不可少的。,特征三、 Classification(分 類),OO uses classification to group objects that have attributes and behaviors in common. the class definitions and hierarchies are intended to represent a problem or its solution; two different

7、 representations may be equally correct or useful. We say that each object is an instance of a class. Each instance has own attribute values but shares attribute names and behaviors with the other instances of the class. OO使用分類來(lái)給某些有著共同屬性和行為的對(duì)象分組。 類定義和層次是用來(lái)表示問(wèn)題或它的解決方法的,兩種不 同的表示方法可能同樣是正確的或有用的。每個(gè)對(duì)象都是 某

8、個(gè)類的實(shí)例。每個(gè)實(shí)例有它自己的屬性值,但和該類的 其他實(shí)例共享屬性名稱和行為。,Examples of objects grouped into classes 對(duì)象歸類的例子,框表示某個(gè)對(duì)象的名稱、屬性和行為,特征四、Encapsulation(封裝),A class encapsulates an objects behaviors and attributes, hiding the implementation details. Encapsulation is then technique for packaging the information in such a way as

9、to hide what should be hidden, and make visible what is intended to be visible. 類封裝了某個(gè)對(duì)象的行為和屬性,隱藏了具體的 實(shí)現(xiàn)。封裝是某種將應(yīng)該隱藏的信息包裝起來(lái), 并使那些應(yīng)該可見(jiàn)的信息變得可見(jiàn)的技術(shù)。,特征五、Inheritance(繼承),Some attributes are shared among the members of a given class. We can organize classes hierarchically according to the sameness or diffe

10、rence among each; this hierarchy exhibits the OO classes inheritance structure. a subclass may inherit the structure as well as the behavior and attributes of its superclass. Sometimes we use an abstract class to simplify the hierarchy. 某些屬性在特定類的成員間是共享的。我們可以根 據(jù)類之間的相同或差異來(lái)構(gòu)造類的層次,這個(gè)層次存 在于OO類的繼承結(jié)構(gòu)中。某個(gè)子類

11、可以繼承父類的結(jié) 構(gòu)、行為和屬性。有時(shí)我們會(huì)用抽象類簡(jiǎn)化層次。,Forming a hierarchy 組成層次,繼承性的含義 對(duì)象共享所在類的結(jié)構(gòu)、操作和約束等語(yǔ)義特性 繼承性的作用 繼承性使所建立的軟件系統(tǒng)具有開(kāi)放性 繼承是信息組織和分類的有效方法 提高代碼可重用率和可靠性,降低開(kāi)發(fā)工作量,特征六、Polymorphism(多態(tài)性),A behavior is an action or transformation that an object performs or to which it is subjected. An objects behavior is triggered by

12、 receipt of a particular message, or entrance into a particular state. Sometimes, the same behavior may be exhibited differently on different classes or subclasses a property call polymorphism. A specific implementation of an operation for a certain class is called a method. In a system with polymor

13、phism, an operation may have more than one method implementing. 行為是某個(gè)對(duì)象執(zhí)行或作用于該對(duì)象的動(dòng)作或變化。接收 到特定信息或加入特定狀態(tài)后觸發(fā)對(duì)象的行為。有時(shí)候,同 樣的行為在不同的類或子類中表現(xiàn)有不同,這種性質(zhì)稱為多 態(tài)性。某個(gè)類的操作的特定實(shí)現(xiàn)稱為方法。在多態(tài)性系統(tǒng) 中,某個(gè)操作可能有不止一種實(shí)現(xiàn)方法。,多態(tài)性含義 把相同的操作施加于不同類型的對(duì)象,獲得不同的結(jié)果 虛函數(shù)(Virtual) 動(dòng)態(tài)聯(lián)編(Dynamic binding),特征七、Persistence(連續(xù)性),The ability of an object

14、s name, state and behaviors to transcend time or space. 某個(gè)對(duì)象的名稱、狀態(tài)和行為超越時(shí)間或 空間的能力。,6.2 The OO development process OO開(kāi)發(fā)過(guò)程,One advantage of OO development is its consistency of language. We can describe both the problem and the solution in the same terms. this across the-process consistency is a key di

15、fference between more traditional procedural development and the OO development process. OO 開(kāi)發(fā)的好處之一在于這種語(yǔ)言的一致性。可 以用同樣的術(shù)語(yǔ)描述問(wèn)題及其解決的方案。整個(gè)過(guò) 程的一致性是傳統(tǒng)程序開(kāi)發(fā)和OO開(kāi)發(fā)過(guò)程的主要 區(qū)別。,OO requirements OO 需求分析,OO requirements analysis is usually done in the users language and discusses the concepts and scenarios likely in

16、the application domain. This expression of the requirement is the same, no matter how the developers decide to implement the system. That is , the requirements definition can independent of its representation as objects. OO需求分析通常是用用戶語(yǔ)言開(kāi)發(fā)的,而且要討 論在應(yīng)用領(lǐng)域可能存在的概念和場(chǎng)景。不管開(kāi)發(fā)人 員決定怎樣實(shí)現(xiàn)系統(tǒng),需求表達(dá)方式是一樣的。也 就是說(shuō),需求定義可以

17、獨(dú)立于對(duì)象的描述。,OO design OO 設(shè)計(jì),In many cases, the OO problem description is same as or similar to the first steps of finding an OO solution. so during OO development, the requirements specification steps may actually be the first steps of system. 在很多情況下,OO問(wèn)題描述與找出OO解決方案的第一步一樣或類似。因此在OO開(kāi)發(fā)過(guò)程中,需求規(guī)格說(shuō)明這一步可能實(shí)際就是

18、系統(tǒng)設(shè)計(jì)的第一步。,OO system design guidelines representing OO設(shè)計(jì)指導(dǎo)方針,First, it is important to identify and represent classes and objects. We must know not only real-world objects but also the details of each objects attributes and behaviors. 首先,確定和表示類和對(duì)象很重要。我們不僅要知道現(xiàn)實(shí)世界的對(duì)象,而且要知道每個(gè)對(duì)象屬性和行為的細(xì)節(jié)。 Second, we must

19、identify the interactions and relationships among objects and classes: their associations, compositions, aggregation, and inheritance relationships. 其次,要確定對(duì)象和類之間的交互和關(guān)系:它們的關(guān)聯(lián)、組合、聚集和繼承關(guān)系,The system design is considered to be a high-level design. Beginning with the system design, the program designers

20、take several steps to provide the details essential for Implementation 系統(tǒng)設(shè)計(jì)是對(duì)程序設(shè)計(jì)的一種高層抽象,從 系統(tǒng)設(shè)計(jì)出發(fā),采用幾個(gè)步驟為實(shí)現(xiàn)提供基本細(xì)節(jié): 1、they insert computational features in models在模型中插 入計(jì)算特征. 2、they insert some class library details, usually using a bottom-up approach通常使用自底向上的方法插入多個(gè)類庫(kù) 的細(xì)節(jié). 3、they consider nonfunction

21、al requirements, such as performance and security, and enhance the design accordingly 考慮非功能性需求,如性能和安全性并由此改進(jìn) 設(shè)計(jì).,OO coding and TestingOO 編碼和測(cè)試,Same activities as other approaches與其他方法一樣,測(cè)試小組測(cè)試,編碼人員測(cè)試,6.3 Use cases 用例,Use Case圖主要用于描述系統(tǒng)和外部環(huán)境的關(guān)系。 Use Case: A use case describes behavior that the system e

22、xhibits to benefit one or more actors.用例是對(duì)系統(tǒng)提供的功能的一種描述。,Use case diagrams have four elements: Actors、 Cases、 Extensions、 Uses. 用例圖有4種元素:執(zhí)行者、實(shí)例、擴(kuò)充、使用。,An actor is a role that an entity plays with respect to the system.執(zhí)行者是和系統(tǒng)進(jìn)行交互的實(shí)體。 The case is a depiction of some aspect of system functionality that

23、 is visible to the actor whose perspective is reflected by the use case.實(shí)例是對(duì)系統(tǒng)功能某方面的描述,執(zhí)行者通過(guò)這些用例反映自己的觀點(diǎn)。 An extension extends a use case to illustrate a different or deeper perspective.擴(kuò)充是對(duì)用例的擴(kuò)展,使之描述不同的或更深的觀點(diǎn)。 A use is actually a reuse of an already-defined use case.使用就是復(fù)用已經(jīng)定義好的用例。,SIDEBAR(附注)6.1,RO

24、YAL SERVICE STATION REQUIREMENTS 皇家服務(wù)站的需求,1.The Royal Service Station provides three types of services to its customers: refueling, vehicle maintenance, and parking. A customer has the option to be billed automatically at the time of purchase or to be sent a monthly paper bill. In either case, custo

25、mers can pay using cash, credit card, or personal check. Royal Service Station fuel is sold according to price per gallon, depending on whether the fuel is diesel, regular, or premium. Service is priced according to the cost of parts and labor. Parking is sold according to daily, weekly, and monthly

26、 rates. The prices for fuel, maintenance services, parts and parking may vary; only the station manager can enter or change price. At his discretion, the station manager may designate a discount on purchases for a particular customer, this discount may vary from one customer to another. A 5% local s

27、ales tax applies to all purchases. 皇家服務(wù)站向顧客提供3種類型的服務(wù):加油、車(chē)輛維護(hù)和停車(chē)。顧客在購(gòu)買(mǎi)服務(wù)時(shí),可以選擇是自動(dòng)開(kāi)賬單還是每月開(kāi)賬單。每種情況顧客都可以使用現(xiàn)金、信用卡或個(gè)人支票進(jìn)行支付。皇家服務(wù)站的燃料是按每加侖的價(jià)格出售的,還取決于燃料是柴油、普通燃料還是優(yōu)質(zhì)燃料。根據(jù)零件及勞動(dòng)的成本制定服務(wù)價(jià)格。根據(jù)每日、每周和每月的價(jià)格出售停車(chē)服務(wù)。加油、維護(hù)服務(wù)、零件和停車(chē)的價(jià)格可能不同;只有該站的經(jīng)理能輸入或改變價(jià)格。經(jīng)理可以隨意為特定顧客指定折扣,每個(gè)顧客的折扣可能不同。所有服務(wù)都要交5%的本地銷(xiāo)售稅。,2.The system must trac

28、k bills on a month-to-month basis and the products and services provided by the gas station on a day-to-day basis. The results of this tracking can be reported to the station manager upon request. 系統(tǒng)必須記錄每月賬單以及加油站每天提供的產(chǎn)品和服務(wù)。當(dāng)經(jīng)理要求時(shí),就可以提交記錄的結(jié)果。,3. The station manager uses the system to control inventor

29、y. The system will warn of low inventory and automatically order new parts and fuel. 經(jīng)理用系統(tǒng)控制存貨。如果存貨較少,系統(tǒng)將會(huì)發(fā)出警告,并能自動(dòng)訂購(gòu)新的零件和燃料。,4.The system will track credit history and send warning letters to customers whose payments are overdue. Bills are sent to customers on the first day of the month after the p

30、urchases are made. Payment is due on the first day of the succeeding month. Any bills not paid within 90 days of the billing date will result in cancellation of the customers credit. 系統(tǒng)會(huì)記錄信用卡歷史記錄,而且當(dāng)付款拖延時(shí)會(huì)給顧客發(fā)出警告通知。交易后的下個(gè)月的第一天會(huì)把賬單寄給顧客。付款在下下個(gè)月的第一天到期。如果貨款在截至日90天內(nèi)還沒(méi)有支付,就會(huì)刪除顧客的信用。,5.The system applies o

31、nly to regular repeat customers. A regular repeat customer means a customer identified by name, address, and birthdate who uses the stations services at least once per month for at least six months. 系統(tǒng)只適用于常客。常客是確定了姓名、地址和生日的顧客,而且每月至少使用一次加油站的服務(wù),至少使用6個(gè)月。,6.the system must handle the data requirements f

32、or interfacing with other systems. A credit card system is used to process credit card transactions for products and services. The credit card system uses the card number, name, expiration date, and amount of purchase. After receiving this information, the credit card system confirms that the transa

33、ction is approved or denied. The parts ordering system receives the part code and number of parts needed. It returns the date of parts delivery. The fuel ordering system requires a fuel order description consisting of fuel type, number of gallons, station name, and station identification code. It re

34、turns the date when the fuel will be delivered. 系統(tǒng)必須處理和其他系統(tǒng)接口的數(shù)據(jù)需求。信用卡系統(tǒng)用來(lái)處理購(gòu)買(mǎi)產(chǎn)品和服務(wù)的信用卡交易。信用卡系統(tǒng)使用卡號(hào)、姓名、截至日期和購(gòu)買(mǎi)金額。接收到這些信息后,信用卡系統(tǒng)就會(huì)確認(rèn)批準(zhǔn)還是拒絕交易。零件訂購(gòu)系統(tǒng)接收需要的零件代碼和數(shù)量。返回交付零件的日期。燃料訂購(gòu)系統(tǒng)要求的燃料訂購(gòu)描述由燃料類型、加侖數(shù)、加油站名稱和加油站確認(rèn)代碼組成。返回何時(shí)交付燃料。,7.the system must record tax and related information, including tax paid by each

35、 customer, as well as tax per item. 系統(tǒng)必須記錄稅收和相關(guān)信息,包括每個(gè)顧客支付的稅款,以及每筆交易的稅款。 8.the station manager must be able to review tax records upon demand. 需要時(shí),經(jīng)理必須能夠檢查稅收記錄。,9.the system will send periodic messages to customers, reminding them when their vehicles are due for maintenance. Normally, maintenance is

36、 needed every six months. 系統(tǒng)會(huì)定期給顧客發(fā)送通知,提醒他們汽車(chē)到維護(hù)的時(shí)間了。正常情況下,每六個(gè)月需要進(jìn)行一次維護(hù)。,10.customers can rent parking spaces in the station parking lot on a day-to-day basis. Each customer must request from the system an available parking space. The station manager can view a monthly report summarizing how many pa

37、rking summarizing how many parking spaces were available or occupied. 顧客可以按天租借加油站停車(chē)場(chǎng)的停車(chē)位。顧客必須向系統(tǒng)請(qǐng)求提供可用的停車(chē)位置。經(jīng)理可以查看月報(bào)告了解有多少停車(chē)位可用或已被占用。,11.the system maintains a repository of accounting information, accessible by account numbers and by customer name. 系統(tǒng)維護(hù)一個(gè)賬戶信息庫(kù),根據(jù)賬戶號(hào)碼和顧客名稱進(jìn)行訪問(wèn)。 12. The station manag

38、er must be able to review accounting information upon demand. 需要時(shí),經(jīng)理必須能夠查看賬戶信息。,13.the system can report an analysis of prices and discounts to the station manager upon request. 根據(jù)經(jīng)理提出的要求,系統(tǒng)能夠給出對(duì)價(jià)格和折扣的分析報(bào)告。 14.the system will automatically notify the owners of dormant accounts. That is, customers wh

39、o did not make services station purchases over a two-month period will be contacted. 系統(tǒng)能夠自動(dòng)通知停用賬戶的所有者,即,會(huì)聯(lián)系那些超過(guò)兩個(gè)月沒(méi)有購(gòu)買(mǎi)加油站服務(wù)的顧客。,15. the system cannot be unavailable for more than 24 hours. 系統(tǒng)不能連續(xù)停用超過(guò)24小時(shí)。 16. the system must protect customer information from unauthorized access. 如果沒(méi)有授權(quán),系統(tǒng)應(yīng)禁止訪問(wèn)顧客的信息。

40、,Example :Overview of royal service station,用例描述外部實(shí)體如何與系統(tǒng)交互的可能場(chǎng)景。服務(wù)站執(zhí)行3類服務(wù):加油、停車(chē)、維護(hù)。這個(gè)場(chǎng)景中顧客是執(zhí)行者,每種服務(wù)會(huì)有賬單提供給顧客。,Actor執(zhí)行者,Use case用例,Extensions 擴(kuò)展,可以擴(kuò)展用例圖。如增加執(zhí)行者:經(jīng)理,新服務(wù):預(yù)防性維護(hù)功能等。 再次擴(kuò)充等。,最后擴(kuò)充,Finally, we extend the system ti include all participants. To do that, we look for all entities in the environm

41、ent (that is, outside the system to be build) that interact with the system to accomplish a task or provide a service. 最后,擴(kuò)展系統(tǒng),讓它包括所有的參與者。為了做到這點(diǎn),查找環(huán)境(即,在構(gòu)造的系統(tǒng)之外)中與系統(tǒng)進(jìn)行交互完成某項(xiàng)任務(wù)或提供某項(xiàng)服務(wù)的所有實(shí)體。,We can use a set of questions to help us identify participants(可 以用一組問(wèn)題來(lái)幫助確定參與者): 1、What users or groups use th

42、e system to perform a task(哪些用 戶或小組使用系統(tǒng)完成某項(xiàng)任務(wù))? 2、What users or groups are needed so that the system can perform its functions(系統(tǒng)完成功能時(shí)需要哪些用戶或小組)? 3、What external systems use the system to perform a task(哪些外部 系統(tǒng)使用系統(tǒng)完成任務(wù))? 4、What external systems, users or groups send information to the System(哪些外部系統(tǒng)、

43、用戶或小組給系統(tǒng)發(fā)送信息)? 5、What external systems, users or groups receive information from the system(哪些外部系統(tǒng)、用戶或小組接收來(lái)自系統(tǒng)的信息)?,Once we have use cases, we can examine them further to find existing and potential problems. for example, we can ask the following kinds of questions: 一旦有了用例,就可以進(jìn)一步檢查它們,看看是否能找出現(xiàn)有的和潛在的問(wèn)

44、題。例如,可以提出以下問(wèn)題:,Do the use cases use the right terminology? That is, are there two or more terms to describe the same entity or actor in the requirements? 用例是否使用了正確的術(shù)語(yǔ)?也就是說(shuō),需求中是否有兩個(gè)或更多的術(shù)語(yǔ)描述了同一個(gè)實(shí)體或執(zhí)行者?,Do the activities match the perspectives? That is, does a use case describe system interaction with

45、a participant in a way that is consistent with the description of the participant itself? 活動(dòng)是否和觀點(diǎn)匹配?也就是說(shuō),用例描述系統(tǒng)和參與者交互的方式是否與參與者自己的描述一致?,Are the descriptions of activities and participants clear and complete? Is there more than one way to interpret the description? 對(duì)活動(dòng)和執(zhí)行者的描述是否清楚而完整?是否有不止一種方法解釋描述?,Is

46、there an interaction described that is missing its complementary participant description? 描述某種交互活動(dòng)時(shí),是否遺漏了對(duì)候補(bǔ)參與者的描述?,Is it clear when each activity start and ends? 每個(gè)活動(dòng)的開(kāi)始和結(jié)束是否明確?,Is there an external system or set of users described but not actually involve in an activity or interaction with the sys

47、tem? 是否描述了某個(gè)外部系統(tǒng)或一組用戶,但實(shí)際上沒(méi)有參與系統(tǒng)的某個(gè)活動(dòng)或交互?,用例圖示例,Actor與Use Case間的連線稱為通信關(guān)聯(lián),表示Actor與相應(yīng)Use Case的交互。 無(wú)論有無(wú)箭頭,通信關(guān)聯(lián)都表示雙向會(huì)話,箭頭表示Actor觸發(fā)Use Case。,Decide on a standard for use case specification 確定用例說(shuō)明的標(biāo)準(zhǔn) Write use cases in structured English 用結(jié)構(gòu)化英語(yǔ)書(shū)寫(xiě)用例 Primary actors trigger the use case 主動(dòng)執(zhí)行者觸發(fā)用例 Second acto

48、rs do not trigger the use case 被動(dòng)執(zhí)行者不觸發(fā)用例 Preconditions constrain the state of the system before the use case can start 前置條件是用例開(kāi)始前的系統(tǒng)狀態(tài) Postconditions constrain the state of the system after the used case has executed 后置條件是用例執(zhí)行后的系統(tǒng)狀態(tài) The main flow describes “perfect world” steps in a use case 主流描述了用

49、例中“理想世界”的活動(dòng)步驟,Use case specification,Use case specification,use case 名,use case 標(biāo)識(shí),概要描述,關(guān)聯(lián)的執(zhí)行者,用例可執(zhí)行前的系統(tǒng)狀態(tài),執(zhí)行步驟,可選流,用例執(zhí)行后的系統(tǒng)狀態(tài),事件流中的分支:Keyword If,事件流中的循環(huán):Keyword For,事件流中的循環(huán):Keyword While,Modeling the alternative flows,Each use case has one main flow and may have many alternative flows. Alternative

50、flows often do not return to the use case main flow.,use case,main flow,alternative flow,Alternative flows may be triggered in three different ways:可選流可以被3種不同的方式觸發(fā) 1. The alternative flow may be triggered instead of the main flow.(替代主流) 2. The alternative flow may be triggered after a particular ste

51、p in the main flow. (1. The alternative flow begins after step X of the main flow.) 3. The alternative flow may be triggered at any time during the main flow. (1.The alternative flow begins at any time.) Should you wish the alternative flow to return to the main flow, you can express this as follows

52、: N. The alternative flow returns to step M of the main flow.,Modeling the alternative flows,6.4 representing OO: an example using UMLOO的表示:一個(gè)UML示例,UML Unified Modeling Language 統(tǒng)一建模語(yǔ)言 Directly unifies the methods of Booch, Rumbaugh ,Jacobson and standardization process with OMG(Object Management Gr

53、oup) UML融合了Booch等方法中的基本概念,而且這些基本概念與其他面向?qū)ο蠹夹g(shù)中的基本概念大多相同; UML不僅僅是上述方法的簡(jiǎn)單匯合,而是擴(kuò)展了現(xiàn)有方法的應(yīng)用范圍;,UML是標(biāo)準(zhǔn)的建模語(yǔ)言,而不是標(biāo)準(zhǔn)的開(kāi)發(fā)過(guò)程。盡管UML的應(yīng)用必然以系統(tǒng)的開(kāi)發(fā)過(guò)程為背景,但由于不同的組織和不同的應(yīng)用領(lǐng)域,需要采取不同的開(kāi)發(fā)過(guò)程。,UML的定義,UML的語(yǔ)義 描述基于UML的精確元模型定義。 元模型為UML的所有元素在語(yǔ)法和語(yǔ)義上提供了簡(jiǎn)單、一致、通用的定義性說(shuō)明,使開(kāi)發(fā)者能在語(yǔ)義上取得一致,消除了因人而異的最佳表達(dá)方法所造成的影響。此外UML還支持對(duì)元模型的擴(kuò)展定義。 UML表示法 定義UML符號(hào)的

54、表示法,為開(kāi)發(fā)者或開(kāi)發(fā)工具使用這些圖形符號(hào)和文本語(yǔ)法為系統(tǒng)建模提供了標(biāo)準(zhǔn)。這些圖形符號(hào)和文字所表達(dá)的是應(yīng)用級(jí)的模型,在語(yǔ)義上它是UML元模型的實(shí)例。,UML的用于描述模型的基本詞匯(“構(gòu)造塊”): 事物(Things)(要素) 關(guān)系(Relationships) 圖 (Diagrames),事物(Things) 結(jié)構(gòu)事物(Structure Thing) UML中的靜態(tài)元素:類、接口、協(xié)作等 行為事物(Behavioral Thing) UML中的靜態(tài)元素:交互(Interaction)、狀態(tài)機(jī)(State Machine) 組織事物(Grouping Thing) UML的分組元素:包(Pa

55、ckage) 注釋事物(Annotation Thing) 注釋(Note),關(guān)系(Relationships) 關(guān)聯(lián)關(guān)系(Association) 依賴關(guān)系(Dependency) 泛化關(guān)系(Generalization) 實(shí)現(xiàn)關(guān)系(Realization) 圖(Diagrames) 9種圖,UML的9種圖,包圖: 包中的類以及包與包之間的關(guān)系(靜態(tài)圖),UML的9個(gè)模型,UML的5種視圖,在UML 中,系統(tǒng)的表示使用5種不同的“視圖” ( UML定義的五類圖,共 9 種圖形),它們可以從軟件開(kāi)發(fā)的不同階段、不同視角 和不同層次對(duì)所開(kāi)發(fā)的系統(tǒng)進(jìn)行描述。每個(gè)視圖由一組圖定義。 用戶模型視圖:使

56、用use-case建模 結(jié)構(gòu)模型視圖:對(duì)靜態(tài)結(jié)構(gòu)(類、對(duì)象和關(guān)系)建模 行為模型視圖:使用表示系統(tǒng)的動(dòng)態(tài)或行為 實(shí)現(xiàn)模型視圖:表示系統(tǒng)的結(jié)構(gòu)和行為 環(huán)境模型視圖:表示系統(tǒng)將實(shí)現(xiàn)的環(huán)境的結(jié)構(gòu)和行為,UML的5種視圖,UML can be used to visualize, specify, or document a problem. UML diagrams include the dynamic view of the system, the static view, restrictions, and formalization. The dynamic view is depicted

57、 with use cases, lists of activities, interaction diagrams showing sequences and collaboration, and state machines to illustrate state and their changes. 可以使用UML可視化、定義或記錄一個(gè)問(wèn)題。UML圖包括系統(tǒng)的動(dòng)態(tài)視圖、靜態(tài)視圖、約束和形式化。動(dòng)態(tài)視圖描述了用例、活動(dòng)列表、顯示順序和協(xié)作的交互圖以及描述狀態(tài)和變化的狀態(tài)圖。,The static view is depicted with class diagrams, showing r

58、elationships (association, generalization, dependency, and realization) and extensibility (constraints, tagged values, and stereotypes). In addition, the static view shows packages and deployment. Restrictions and formalization are expressed with OCL, an Object Constraint Language. 靜態(tài)視圖描述了類圖,給出了關(guān)系(關(guān)

59、聯(lián)、泛化、依賴和實(shí)現(xiàn))以及擴(kuò)展(約束、標(biāo)記值和模板)。另外靜態(tài)視圖還包括包和配置。約束和形式化用某種對(duì)象約束語(yǔ)言O(shè)CL表示。,Because OO concepts apply to all parts of development, UML can used throughout the software development process.由于開(kāi)發(fā)的所有部分都使用了OO概念, 所以可以將UML應(yīng)用在軟件開(kāi)發(fā)過(guò)程的整個(gè)階段。,UML用于軟件系統(tǒng)開(kāi)發(fā)的不同階段,用戶需求: 可使用用例圖來(lái)捕獲用戶的需求,用例圖從用戶的角度來(lái)描述系統(tǒng)的功能,表示了操作者于系統(tǒng)的一個(gè)交互過(guò)程。 系統(tǒng)分析: 可使用類圖來(lái)描述系統(tǒng)的 靜態(tài)模型,為了實(shí)現(xiàn)用例、類之間需要協(xié)作,可用動(dòng)態(tài)模型的狀態(tài)圖、順序圖、協(xié)作圖來(lái)描述。 分析階段只考慮問(wèn)題域的對(duì)象建模。需要通過(guò)靜態(tài)模型和動(dòng)態(tài)模型來(lái)描述系統(tǒng)結(jié)構(gòu)和系統(tǒng)行為。 系統(tǒng)設(shè)計(jì): 對(duì)類進(jìn)行細(xì)化,如引入人機(jī)交互的接口類、處理數(shù)據(jù)類、處理通信類。 系統(tǒng)實(shí)現(xiàn): 用構(gòu)件圖描述代碼構(gòu)件的物理結(jié)構(gòu)以及構(gòu)件之間的關(guān)系。用配置圖來(lái)描述和定義系統(tǒng)中軟硬件的物理通信結(jié)構(gòu)。 測(cè)試: 可使用類圖進(jìn)行單元測(cè)試;可使用構(gòu)件圖、協(xié)作圖進(jìn)

溫馨提示

  • 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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論