Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP 3331 OBJECT-ORIENTED ANALYSIS AND DESIGN Bob Myers Department of Computer Science Week 6 Lecture.

Similar presentations


Presentation on theme: "COP 3331 OBJECT-ORIENTED ANALYSIS AND DESIGN Bob Myers Department of Computer Science Week 6 Lecture."— Presentation transcript:

1 COP 3331 OBJECT-ORIENTED ANALYSIS AND DESIGN Bob Myers Department of Computer Science Week 6 Lecture

2 Definition: Object Modeling w Main goal: Find the important abstractions w What happens if we find the wrong abstractions? Iterate and correct the model w Steps during object modeling 1. Class identification Based on the fundamental assumption that we can find abstractions 2. Find the attributes 3. Find the operations/methods 4. Find the associations between classes w Order of steps secondary, only a heuristic w Iteration is important

3 UML: Class and Instance Diagrams Inspector joe: Inspector mary: Inspector anonymous: Inspector Class Diagram Instance Diagram

4 Attributes and Values name:string age: integer Inspector name = “Joe” age = 24 joe:Inspector name = “Mary” age = 18 mary: Inspector

5 1-to-1 and 1-to-many Associations Has- capital One-to-one association One-to-many association City name:String WorkOrder schedule() Task x: Integer y: Integer z: Integer * Country name:String

6 Aggregation w Models "part of" hierarchy w Useful for modeling the breakdown of a product into its component parts (sometimes called bills of materials (BOM) by manufacturers) w UML notation: Like an association but with a small diamond indicating the assembly end of the relationship.

7 weight Automobile serial number year manufacturer model color drive purchase Aggregation Engine horsepower volume on off 3,4,5 Wheel diameter number of bolts 2,4 Door open close Battery amps volts charge discharge * Brakelight on off

8 Inheritance w Models "kind of" hierarchy w Powerful notation for sharing similarities among classes while preserving their differences w UML Notation: An arrow with a triangle Cell MuscleCellBloodCellNerveCell StriateSmoothRedWhitePyramidalCortical

9 Object Types w Entity Objects Represent the persistent information tracked by the system (Application domain objects, “Business objects”) w Boundary Objects Represent the interaction between the user and the system w Control Objects: Represent the control tasks performed by the system w Having three types of objects leads to models that are more resilient to change. The boundary of a system more likely to change than the control of the system

10 Example: 2BWatch Objects w UML provides several mechanisms to extend the language w UML provides the stereotype mechanism to present new modeling elements Attach meta information to a diagram inside > tags Naming conventions good for clarity > Year > Month > Day > ChangeDateControl > LCDDisplayBoundary > ButtonBoundary

11 Roles w A role name is the name that uniquely identifies one end of an association. w A role name is written next to the association line near the class that plays the role. w When do you use role names? Necessary for associations between two objects of the same class Also useful to distinguish between two associations between the same pair of classes w When do you not use role names? If there is only a single association between a pair of distinct classes, the names of the classes serve as good role names

12 Example of Role Problem Statement:A person assumes the role of repairer with respect to another person, who assumes the role of inspector with respect to the first person. Person * Creates Workorders inspector repairperson * Creates Workorders Person

13 Qualification w The qualifier improves the information about the multiplicity of the association between the classes. w It is used for reducing 1-to-many multiplicity to 1-1 multiplicity With qualification: A directory has many files, each with a unique name Without qualification: A directory has many files. A file belongs only to one directory. DirectoryFile filename Directory File filename 1* 0..1 1

14 Example Problem Statement:A stock exchange lists many companies. However, a stock exchange lists only one company with a given ticker symbol.A company may be listed on many stock exchanges, possibly with different ticker symbols. Find company with ticker symbol AAPL. StockExchange Company tickerSym ** lists

15 Use of Qualification reduces multiplicity StockExchangeCompany tickerSym 0..1 1 StockExchange Company tickerSym **

16 Object Modeling in Practice: Heuristics w Explicitly schedule meetings for object identification w Try to differentiate between entity, boundary and control objects w Find associations and their multiplicity Unusual multiplicities usually lead to new objects or categories w Identify Aggregation w Identify Inheritance: Look for a Taxonomy, Categorize w Allow time for brainstorming, Iterate, iterate

17 Identifying Associations w Examine verb phrases for association roles w Use qualifiers when possible to reduce multiplicities w Avoid “ravioli” models Too many associations can get too complex Delete redundant associations (i.e. too many paths between two types of object) FieldOfficerEmergency Report Incident writes reports triggers (Can remove 1 of the 3 associations) 1 1 1 1 1*

18 Identifying Attributes w Examine possessive or adjective phrases E.g. the description “of an emergency” w Represent the stored state of an entity object as attribute variables w If an attribute could be made an object, use an association to the object instead (e.g. aggregation) w The details will likely change, so wait until the analysis model is stable before describing all of the details


Download ppt "COP 3331 OBJECT-ORIENTED ANALYSIS AND DESIGN Bob Myers Department of Computer Science Week 6 Lecture."

Similar presentations


Ads by Google