An Introduction to Object-Oriented AnalysisObjects and UML .ppt

上传人:medalangle361 文档编号:378299 上传时间:2018-10-09 格式:PPT 页数:125 大小:318KB
下载 相关 举报
An Introduction to Object-Oriented AnalysisObjects and UML .ppt_第1页
第1页 / 共125页
An Introduction to Object-Oriented AnalysisObjects and UML .ppt_第2页
第2页 / 共125页
An Introduction to Object-Oriented AnalysisObjects and UML .ppt_第3页
第3页 / 共125页
An Introduction to Object-Oriented AnalysisObjects and UML .ppt_第4页
第4页 / 共125页
An Introduction to Object-Oriented AnalysisObjects and UML .ppt_第5页
第5页 / 共125页
亲,该文档总共125页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、An Introduction to Object-Oriented Analysis Objects and UML in plain English. Chapter 5: Objects and Classes,Based on the book by David William Brown,John Wiley & Sons, ISBN 0471371378,Copyright,Copyright 8 2002 Flying Kiwi Productions All rights reserved.This slide presentation is based on “An Intr

2、oduction to Object-Oriented Analysis; Objects and UML in Plain English,” by David William Brown, Wiley, ISBN 0471371378, “The Book.” Permission is hereby granted to copy, modify or excerpt all or any part of this slide presentation, provided it is solely for use with courses, seminars or other prese

3、ntations or productions where a copy of The Book is purchased by or for each and every participant or recipient.An instructor guide is available free from the publisher for use with such presentations.,Chapter 5: Objects and Classes,5.1. Real-World vs Data-World Objects 5.2. Classes and Classificati

4、on 5.3. Transient and Persistent Objects 5.4. Objects: Classes or Instances? 5.5. Associations 5.6. Anthropomorphism,5.1. Real-World vs Data-World Objects Here is what its all about:,We Analysts must understand and document the real world where our users live. We then create a product in the compute

5、r world, To help the users do their job in the real world. Effective analysts must ensure the computer-world product accurately mirrors the users real-world needs.,This is why our jobs exist!,5.1. Real-World vs Data-World Objects,5.1. Real-World vs Data-World Objects,What An Object Is In the Real Wo

6、rld In the Data World Jacobsons Three Types Entity Objects Concrete objects Conceptual objects Event and State objects Interface Objects Control Objects,Attributes Behavior Identity Encapsulation Violating Encapsulation Object States,Now lets look at these in detail. . .,Dictionaries: A thing Can be

7、 seen, touched or otherwise sensed Someone is aware of it A material thing A thing in a picture In other words, an object is a THING.,5.1. Real-World vs Data-World Objects What An Object Is:,“The world is full of things.” From the millions, we choose the ones relevant to our project. We must work cl

8、osely with the users Involve them at every step To ensure we have the objects they need. We look for subclasses among the objects.,5.1. Real-World vs Data-World Objects In the Real World:,Remember, an Object is an Entity with Behavior.,5.1. Real-World vs Data-World Objects In the Real World:,The Wor

9、ld is full of THINGS,THINGS,An object is some Thing in the world of the user Car, Train, Elephant, Sale, Invoice, Division, Account, etc. Physical or Conceptual It has Attributes that describe it: Make, Model, Year, Color, Weight, Serial Number, License Number It has Relationships to other objects:

10、e.g., to a Person object, i.e., the Owner.It has Behavior that it can do: Create Change Color Change Owner Destroy Itself (Suicide?),Entity,Object,in the DATA WORLD,We have some kind of record in the computer for each real-world object It carries data for the attributes Make, Model, Year, Color, Wei

11、ght, Serial Number, License Number The set of attribute values represents the STATE of the object It carries a link of some kind for each relationship Foreign Key or pointerIt carries program code for each behavior Create, Change Owner, Change Color, Delete Itself (Suicide?) CRUD: Create, Read (Gimm

12、e .), Update, Delete.,Entity,Object,Mostly, a Data-World Object is a Representation of a Real-World Object. And since it carries only The data we need for the job at hand, and The behavior (program code) for the job at hand This makes it an abstraction of the real-world object.,5.1. Real-World vs Da

13、ta-World Objects In the Data World:,A Data Object is an abstraction of some thing in the real world, that carries both the data describing the real-world object , and the operations (i.e., program code) that have the only allowable access to that data.,5.1. Real-World vs Data-World Objects We Define

14、:,In an OOPL, an object is created as a piece of RAM Organized into fields (data elements) for the attributes. This is just like the “struct” in C or the “Record” in Pascal. Whats different in objects is that theprogram code is part of the object. It is made available as soon as the object is create

15、d.,5.1. Real-World vs Data-World Objects,Some OOPLs and OODBMSs actually have the compiled code for the methods right there on the disk or in the database. At run time it is executed directly from the disc or database. This is “Late Binding” or “Dynamic Binding.” “Early Binding” or “Static Binding”

16、has the methods stored in semi-compiled form, and they are compiled or linked into the program at compile time.These are discussed in detail in Chapters 8 and 14.,5.1. Real-World vs Data-World Objects,5.1. Real-World vs Data-World Objects Jacobsons Three Types,Entity Objects Interface Objects Contro

17、l Objects,5.1. Real-World vs Data-World Objects Jacobsons Three Types In the interests of stability and resilience to change, Jacobson (pron. Yahcobson) classifies objects into three types:,Lets look at these in detail. . .,5.1. Real-World vs Data-World Objects Jacobsons Three Types,Entity Objects T

18、hese are the ones we have already been discussing. They represent objects in the users real world. All relevant behavior associated with the corresponding real-world object is modeled by the methods.,5.1. Real-World vs Data-World Objects Jacobsons Three Types,Definition:Entity Objects are the fundam

19、ental objects and classes that we discover in Analysis by scanning the users business.,5.1. Real-World vs Data-World Objects Jacobsons Three Types There are three kinds of Entity Objects:,Concrete objects Conceptual objects Event and State objects. . .,5.1. Real-World vs Data-World Objects Jacobsons

20、 Three Types .Concrete Objects:,Solid, tangible and physical. Things you can grab hold of. People, animals and other beings Land, buildings, equipment, vehicles Goods, products, tools, appliances, materialsThese are easily understood by both analysts and users.,5.1. Real-World vs Data-World Objects

21、Concrete Entity Objects,Person Apartment Elevator Food Employee Warehouse Forklift Product Customer House Car Clothes Student College Cell phone Pen Citizen Street Truck Gravel Engineer Office Lathe Steel Animal Farm Tractor Beer Doctor Hospital Scalpel Blood Librarian Library Computer Book Cop Stat

22、ion Gun Bullets,Beings,Land & Buildings,Equipment,Goods,5.1. Real-World vs Data-World Objects Jacobsons Three Types . Conceptual Objects:,Intangible, nonphysical More difficult for users to grasp, But they are still things and objects Typically defined in terms of other object classes . . .e.g., by

23、breaking out a M:M relationship See Chapter 9.,Corporation Strategy Lease Church Plan Mortgage Regiment Map Ceasefire Sports club Schedule Membership Government dept Proposal Approval Professional assn Qualification Charter Union Bylaws Contract,5.1. Real-World vs Data-World Objects Conceptual Entit

24、y Objects,Organizations,Abstractions,Agreements,These are conceptual in the sense that a contract does not consist of a piece of paper. Rather, it is an agreement that comes into existence, The moment the two parties agree, verbally or otherwise. Signing the piece of paper documents the existence of

25、 the contract,to make it easier to enforce (e.g. in court). An undocumented contract still exists and is enforceable,but you may have problems proving it exists.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Conceptual Objects:,Also very abstract in nature. When an Event occurs, some o

26、bject will change its State. When a business event occurs, it is documented,and that is a fact we must record, i.e., it is Data.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Event and State Objects:,A state is a condition or situation. At any time an object exists in a certain state.

27、Sometimes the state is more important to our project than the object, in which case, for us,the state itself is a thing, and an object.,5.1. Real-World vs Data-World Objects Jacobsons Three Types State Objects:,Purchase Deposit Ownership Enrolment Delivery Loan Suspense Assignment Negotiation Return

28、 Birth Termination Arrival Hire Status Immigrant Departure Rental Licence Registration Transaction Sale In Transit Employment,5.1. Real-World vs Data-World Objects Event and State Entity Objects,Events,States,Most software systems need to exchange data with other systems.,5.1. Real-World vs Data-Wor

29、ld Objects Jacobsons Three Types Interface Objects:,These might be: Other information systems, such as Human Resources, Accounting, etc., etc. A real-world system controlled by our software Industrial processes, refineries, etc. Machinery, robots, assembly lines, etc. Monitoring systems Security sys

30、tems, Intensive Care Units, etc.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Interface Objects:,These days, they might also be: Communications Interfaces Point-to-Point Modem and phone line Fax and Fax-back LAN, WAN, etc. Internet and/or Intranet Peripheral devices e.g. printers, sca

31、nners, sound and video Input/Output. Graphical User Interfaces (GUIs),5.1. Real-World vs Data-World Objects Jacobsons Three Types Interface Objects:,Suppose you developed a system that needed to communicate over modem lines.For simplicity, during testing you might just plug two serial ports together

32、 from one machine to another.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Interface Objects:,When the software is deployed, we find things have changed - it must communicate over a LAN.And then what if the needs grew and the users wanted it to work across the Internet? Well, . .,5.1.

33、 Real-World vs Data-World Objects Jacobsons Three Types Interface Objects:,To handle this, we would hide all the processing to do with the comm link within an object. When the changes happen, we rewrite some of the methods within this class, And add an attribute or two. Nothing outside this class ne

34、eds to be touched!,5.1. Real-World vs Data-World Objects Jacobsons Three Types Interface Objects:,The complexity of the interface is hidden within the interface object. All the interface processing is hidden,And can be changed to handle changes such as the communications medium . . . .,5.1. Real-Wor

35、ld vs Data-World Objects Jacobsons Three Types Interface Objects, Advantages:,Without upsetting the rest of the system.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Interface Objects, Advantages:,This is an example of Encapsulation, or Information Hiding, which we explore later in thi

36、s chapter.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Interface Objects, Advantages:,One reason this form of encapsulation is so important is thatThe interfaces to other systems are the least stable aspect of any information system. . .,5.1. Real-World vs Data-World Objects Jacobson

37、s Three Types Interface Objects, Advantages:,5.1. Real-World vs Data-World Objects Jacobsons Three Types Interface Objects, Advantages:,Other Interfaces,Outputs,User Interface,Object Behavior,Object Attributes,Object Classes,Sometimes we find a method (subroutine, function) that uses data, and calls

38、 other methods, from many different objects and classes. These methods dont easily fit or dont logically belong in any of our entity classes or interface classes.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Control Objects:,So we create a class just to have somewhere to put this meth

39、od; This we call a Control Class.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Control Objects:,Sometimes this control class will have just this one method. Nothing else, no attributes, no nothing! Other times it will need a few attributes for intermediate results, etc. And perhaps a

40、few other methods.,5.1. Real-World vs Data-World Objects Jacobsons Three Types Control Objects:,Definition: Control Objects are created during Analysis or Design to give us somewhere to put behavior that doesnt easily fit into existing interface or entity objects.,5.1. Real-World vs Data-World Objec

41、ts Jacobsons Three Types Control Objects:,5.1. Real-World vs Data-World Objects So far, we have looked at all these:,What An Object Is In the Real World In the Data World Jacobsons Three Types Entity Objects Concrete objects Conceptual objects Event and State objects Interface Objects Control Object

42、s,5.1. Real-World vs Data-World Objects Summary:,An object in the real world is a thing, and data about it is carried by its corresponding data-world object. Our system gains in stability when data is organized around the objects it describes.,A data object is an abstraction of a real-world object,

43、And carries the data describing it,and the program code (i.e., the method code) that is the only allowable access to that data.,5.1. Real-World vs Data-World Objects Summary:,5.1. Real-World vs Data-World Objects Summary: Jacobsons Three Types,Entity Objects match the real-world ones. They are of th

44、ree kinds: Concrete Objects e.g., Customers, Products, Vehicles. Solid, tangible, physical. Conceptual Objects e.g., Companies, Strategies, Mortgages. abstract, nonphysical, often result from M:M Event & State Objects e.g., Sale, Loan, Employment. Often result from documenting an event.,5.1. Real-Wo

45、rld vs Data-World Objects Summary: Jacobsons Three Types,Interface Objects handle data exchanged with users or other systems. They encapsulate the communications protocols and processing.Control Objects are created to handle complex operations that do not fit naturally in any one object or class.,5.

46、1. Real-World vs Data-World Objects Weve looked at these, Now lets look at these in detail. . .,What An Object Is In the Real World In the Data World Jacobsons Three Types Entity Objects Concrete objects Conceptual objects Event and State objects Interface Objects Control Objects Summary,Attributes

47、Behavior Identity Encapsulation Violating Encapsulation Object States,5.1. Real-World vs Data-World Objects Attributes,A child concludes there are objects out there And notices some properties they have e.g., Color, softness, taste, warmth, etc. The child is gathering data about these objects We wil

48、l call each such data item an Attribute These Attributes fit our earlier definition. Thus, we build a mental model in our heads,5.1. Real-World vs Data-World Objects Attributes In the real world:,Each object instance carries a set of attribute values These represent the data items that a user might

49、need to knowabout the object at any time Data types and sizes are defined for the class And apply to every instance. The domain of an attribute is its set of all permissible values.,5.1. Real-World vs Data-World Objects Attributes In the data world:,5.1. Real-World vs Data-World Objects Behavior,A child makes two observations about the objects surrounding her: They have attributes, and They DO things. And she learns to influence that behavior by sending them messages,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 教学课件 > 大学教育

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1