华师大面向对象程序设计-Lec06寻找分析类图中的类_第1页
华师大面向对象程序设计-Lec06寻找分析类图中的类_第2页
华师大面向对象程序设计-Lec06寻找分析类图中的类_第3页
华师大面向对象程序设计-Lec06寻找分析类图中的类_第4页
华师大面向对象程序设计-Lec06寻找分析类图中的类_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Object-oriented Analysis &Design面向对象分析与设计Lecture_02 Analysis & Design ConceptPresenter: Xiaohong Chen陈小红2022-2-19OutlinenOOAD processnOO analysis phasenOO design phase22022-2-193Analysis PhasenIn software engineering, analysis is the process of converting the user requirements to system spec

2、ification (system means the software to be developed). nSystem specification, also known as the logic structure, is the developers view of the system. nWhat the business logic is (existed )nWhat the business logic should be (suggested)nTwo ways for a large systemnFunction-oriented analysis n concent

3、rating on the decomposition of complex functions to simple ones. nObject-oriented analysis n identifying objects and the relationships between objects. 2022-2-194Object Oriented AnalysisnIdentifying objects, using nconcepts, nCRC cards, nStereotype etc.nOrganising the objects: nclassifying the objec

4、ts identified, so similar objects can later be defined in the same class.nIdentifying relationships between objects: nthis helps to determine inputs and outputs of an object.nDefining operations of the objects:n the way of processing data within an object.nAlso known as responsibility assignmentnDef

5、ining objects internally:n information held within the objects. 2022-2-195Three ways to do Object Oriented Analysis (there are more). nConceptual model (Larman)nProduce a “light” class diagram.nCRC cards (Beck, Cunningham)nIndex cards and role playing.nAnalysis model with stereotypes (Jacobson)nBoun

6、daries, entities, control. A good analyst knows more than one strategy and even may mix strategies in order to identify the objects and relationships for the design phase.2022-2-196Conceptual Model - OverviewnA conceptual model is a representation of concepts in a problem domain. nSometime called do

7、main modelnIn UML it is basically a “class diagram without operations”.nIt may show: nConceptsnAssociations of conceptsnAttributes of concepts2022-2-197Finding Concepts with Noun Phrase IdentificationnIdentify the noun and noun phrases in textual descriptions of a problem domain and consider them as

8、 candidate concepts or attributes.nCare must be applied with this method.nA mechanical noun-to-concept mapping isnt possible, and words in natural languages are ambiguous (especially English). 2022-2-198Case Study: Nouns in The Recycling machine - The “return item” Use case.nThe system controls a re

9、cycling machine for returnable bottles, cans and crates(板条箱). The machine can be used by several customers at the same time and each customer can return all three types of item on the same occasion. The system has to check, for each item, what type has been returned. nThe system will register how ma

10、ny items each customer returns and when the customer asks for a receipt, the system will print out what was deposited , the value of the returned items and the total return sum that will be paid to the customer. nAn operator also (not in “return item” Use Case)2022-2-199Case Study: Nouns in The Recy

11、cling machine - The “return item” Use case.nThe system controls a recycling machine for returnable bottles, cans and crates. The machine can be used by one customer at the same time and each customer can return all three types of item on the same occasion. The system has to check, for each item, wha

12、t type has been returned. nThe system will register how many items each customer returns and when the customer asks for a receipt, the system will print out what was deposited , the value of the returned items and the total return sum that will be paid to the customer. nAn operator also (not in “ret

13、urn item” Use Case)2022-2-1910Case Study: Nouns found in the description:nrecycling machine nbottles, cans, and crates nmachine ncustomer ntypes of item, item, type, returned itemsnsystem nreceiptnreturn sum2022-2-1911Case Study: Discussion of “recycling machine”. nrecycling machine nbottles, cans a

14、nd crates nmachine ncustomer ntypes of item, item, type, returned itemsnsystem nreceiptnreturn sumnThis concept is the “overall system”. As we consider only one single use case, it is better to name this concept in the context of this use case, e.g. nDeposit item receiver2022-2-1912Case Study: Discu

15、ssion of “bottles, cans, and crates”. ndeposit item receiver nbottles, cans, and crates nmachine ncustomers, customer ntypes of item, item, type returned itemsnsystem nreceiptnreturn sumnIn a conceptual model it is usually better to use singular and multiplicities instead of plural.nAs bottle, can a

16、nd crate have much in common (they are processed as items), they could be generalised to an “item”. nWe should remember this for later (inheritance). 2022-2-1913Case Study: Discussion of “machine” and “system”. ndeposit item receiver nbottle, can, crate nmachine ncustomer ntypes of item, item, type,

17、 returned itemsnsystem nreceiptnreturn sumn“Machine” and “System” mean here the same, namely the “Recycling machine”, i.e. thenDeposit item receiver 2022-2-1914Case Study: Discussion of “customers” and “customer”. ndeposit item receiver nbottle, can, crate n ncustomer ntypes of item, item, type, ret

18、urned itemsn nreceiptnreturn sumnThe customer has already been identified as an actor.nThey are outside of the system.nWe establish a concept, that interfaces with the customer (and is inside the system): nCustomer paneln (Note: this is a fabled idea)2022-2-1915nThe items that are inserted in the ma

19、chine.nGood candidate as superclass for bottle, can, crate.nLets call itnDeposit item, ( instead of item) Case Study: Discussion of “item” (etc.). ndeposit item receiver nbottle, can, crate n ncustomer panel ntypes of item, item, type, returned itemsn nreceiptnreturn sum2022-2-1916Case Study: Discus

20、sion of “receipt”. ndeposit item receiver nbottle, can, crate n ncustomer panel ndeposit itemn nreceiptnreturn sumnThe concept that “remembers” all items inserted in the machine. nTo distinguish it from the piece of paper returned to the customer, call itnReceipt basis2022-2-1917Case Study: Discussi

21、on of “return sum”. ndeposit item receiver nbottle, can, crate n ncustomer panel ndeposit itemn nreceipt basisnreturn sumnThe sum that it is returned to the customer is actually computed by adding up all values of the items stored in the receipt basis. nThe sum itself is only a primitive data value,

22、 and may therefore not be considered as a concept. 2022-2-1918Case Study: Discussion of other concepts. ndeposit item receiver nbottle, can, crate n ncustomer panel ndeposit itemn nreceipt basisn nThese are the concepts identified by nouns. Did we forget something? 2022-2-1919Case Study: Nouns in Th

23、e Recycling machine - The “return item” Use case.nThe system controls a recycling machine for returnable bottles, cans and crates. The machine can be used by one customer at the same time and each customer can return all three types of item on the same occasion. The system has to check, for each ite

24、m, what type has been returned. nThe system will register how many items each customer returns and when the customer asks for a receipt, the system will print out what was deposited , the value of the returned items and the total return sum that will be paid to the customer. nAn operator also (not i

25、n “return item” Use Case)2022-2-1920Case Study: Discussion of other concepts. ndeposit item receiver nbottle, can, crate n ncustomer panel ndeposit itemn nreceipt basisn nThese are the concepts identified by nouns. Did we forget something? nCheck the “Concept Category List” !nThe system “interfaces”

26、 with the physical object “printer”, so we add an interface conceptnReceipt printer 2022-2-1921Case Study: Summary of concepts identified in the analysis ndeposit item receiver nbottle, can, crate n ncustomer panel ndeposit itemn nreceipt basisn nreceipt printer nSo far we have identified:nConceptsn

27、A generalisation relationship.nNext step: Finding associations. 2022-2-1922How to make a conceptual model.nFind the conceptsnDraw them in a conceptual modelnAdd associationsnAdd attributes2022-2-1923Drawing of ConceptsCustomer panelDeposit item receiverReceipt basisDeposit itemReceipt printerCanBott

28、leCrate2022-2-1924Adding AssociationsnIf one concept needs to know of another concept for some duration, they should be linked by an association. nAdd “Adornment” to associationnAlso use the following list in order to identify associations. 2022-2-1925Common Association List(Ch 9.14)nA is a part of

29、BnA is contained in BnA is a description for BnA is a line item of BnA is known or reported in BnA is a member of BnA is a organisational subunit of BnA uses or manages BnA communicates with BnA is related to a transaction BnA is a transaction related to another transaction BnA is next to BnA is own

30、ed by B2022-2-1926Adding associationsnThe Customer panel communicates to the receiver when an item is inserted.nAlso when the receipt is requested. Customer panelDeposit item receiverReceipt basisDeposit itemReceipt printerCanBottleCrateinitiates action2022-2-19OOAD Lecture, Author: NK Jiang27/77Add

31、ing associationsnThe Deposit item receiver manages Deposit items:nThe items are classified.Customer panelDeposit item receiverReceipt basisDeposit itemReceipt printerCanBottleCrateinitiates actionclassifies2022-2-1928/77Adding associationsnThe Deposit item receiver communicates to Receipt basis:nIte

32、ms received and classified are stored.nIt also creates the receipt basis when it is needed for the first time. Customer panelDeposit item receiverReceipt basisDeposit itemReceipt printerCanBottleCrateinitiates actionclassifiescreates & notifies2022-2-1929Adding associationsnThe Receipt basis cap

33、tures Deposit items.Customer panelDeposit item receiverReceipt basisDeposit itemReceipt printerCanBottleCrateinitiates actionclassifiescreates & notifiescaptures2022-2-1930Adding associationsnOn request by the Customer Panel, the Deposit item receiver initiates printing of a receipt on the print

34、er. Customer panelDeposit item receiverReceipt basisDeposit itemReceipt printerCanBottleCrateinitiates actionclassifiescreates & notifiescapturesprints on2022-2-1931Adding associationsnAdding multiplicitiesnOnly one association here is a 1 to many relationshipnAll others are 1 to 1.Customer pane

35、lDeposit item receiverReceipt basisDeposit itemReceipt printerCanBottleCrateinitiates actionclassifiescreates & notifiescapturesprints on1.*2022-2-1932Adding AttributesnAn attribute is a logical data value of an object.nAttributes in a conceptual model are simple data values as nBoolean, Date, N

36、umber, String (Text), Time, Address, Colour, Price, Phone Numbers, Product Codes, etc.nSometimes it is difficult to distinguish between attributes and concepts (CH 9.12)SalestoreOr SaleStorephoneNum?Guideline If we do not think of some conceptual class X as a Number or text in the real world, X is p

37、robably a Conceptual class, not an attribute.2022-2-1933Adding attributesnThe Deposit item has a value. nAlso it will be assigned a number that shows later on the receipt.Customer panelDeposit item receiverReceipt basisDeposit itemnumbervalueReceipt printerCanBottleCrateinitiates actionclassifiescre

38、ates & notifiescapturesprints on1.*2022-2-1934/77Adding attributesnIn order to be classified by the Deposit item receiver each item has also a weight and a size.nHowever this is the same for each type of item, but different between the types. Customer panelDeposit item receiverReceipt basisDepos

39、it itemnumbervalueReceipt printerinitiates actionclassifiescreates & notifiescapturesprints on1.*BottleweightsizeCrateweightsizeCanweightsize2022-2-1935SummarynNOT in a conceptual model:narrowsndotted linesnmethods, operations, functionsCustomer panelDeposit item receiverReceipt basisDeposit ite

40、mnumbervalueReceipt printerinitiates actionclassifiescreates & notifiescapturesprints on1.*BottleweightsizeCrateweightsizeCanweightsize2022-2-1936Good design vs bad designnConsider the following alternative design of the recycling machine.nA class responsible for printing and holding the data of

41、 bottle and crate.nThe can class is also responsible for customer input and computing the sum. nOne more class doing all the rest of the tasks.nIs this a good design?2022-2-1937Good design bad designnOur feeling says that the previous example is not a good design. nIs it possible to give this feelin

42、g a more solid, more objective, more traceable, and more comprehensible foundation?nAnswer: nYes, by using patterns.2022-2-1938Identifying Classes and ObjectsnExample:nA partial requirements document:The user must be allowed to specify each product byits primary characteristics, including its name a

43、ndproduct number. If the bar code does not match theproduct, then an error should be generated to themessage window and entered into the error log. Thesummary report of all transactions must be structuredOf course, not all nouns will correspond toa class or object in the final solution2022-2-1939Ide

44、ntifying Classes and ObjectsnExample nRequirements for an Automated Teller Machine (ATM) nThe ATM system will interact with the customer through a display screen, numeric and special input keys, a bankcard reader, a deposit slot, and a receipt printer. nCustomers may make deposits, withdrawals, and

45、balance inquires using the ATM machine, but the update to accounts will be handled through an interface to the Accounts system. 2022-2-19Whats important to class and objectnRemember that a class represents a group (classification) of objects with the same behaviorsnGenerally, classes that represent objects should be given names that are singular nounsnExamples: Coin, Student, MessagenA class represents the concept of one such objectnWe are free to inStantiate as many of each object as needednGood selection of object names for the instance

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论