Скачать презентацию Conceptual Modeling A Short Discussion Outline l Скачать презентацию Conceptual Modeling A Short Discussion Outline l

729d55a2a7665952ab48bf08ccc478c1.ppt

  • Количество слайдов: 49

Conceptual Modeling A Short Discussion Conceptual Modeling A Short Discussion

Outline l Conceptual modeling n l l The OO solution The object model (conceptual) Outline l Conceptual modeling n l l The OO solution The object model (conceptual) n l The goal of conceptual modeling Syntax and semantics Object modeling approach n Home Heating System

Conceptual Modeling l l Early modeling to understand the problem Conducted in cooperation with Conceptual Modeling l l Early modeling to understand the problem Conducted in cooperation with the customer n Domain experts u l l Domain engineers No real problem analysis if the customer is not involved Power of OO n It is simple and people can quickly participate effectively

The OO Solution l The OO model closely resembles the problem domain n l The OO Solution l The OO model closely resembles the problem domain n l Base your model on the objects in the problem domain Iteratively refine the high-level model until you have an implementation n Attempt to avoid big conceptual jumps during the development process

Objects State of Michigan Drivers License J. Q. Public A-123456 03 -12 -63 VISA Objects State of Michigan Drivers License J. Q. Public A-123456 03 -12 -63 VISA J. Q. Public 123 4567 887766 998

Attributes and Operations Person class Person objects abstracts to Card objects Card class State Attributes and Operations Person class Person objects abstracts to Card objects Card class State of Michigan Drivers License J. Q. Public A-123456 03 -12 -63 Attributes name age height weight Operations move change-job VISA J. Q. Public 123 4567 887766 998 Attributes height width id-number Operations issue change

Characteristics of Objects l Identity n l Classification n l Abstract entities with the Characteristics of Objects l Identity n l Classification n l Abstract entities with the same structure (attributes) and behavior (operations) into classes Polymorphism n l Discrete and distinguishable entities The same operation may behave differently on different classes Inheritance n Sharing of attributes and operations based on a hierarchical relationship

The Class Diagrams The Class Diagrams

Objects l Something that makes sense in the application context (application domain) n n Objects l Something that makes sense in the application context (application domain) n n n l l J. Q. Public Joe’s Homework Assignment 1 J. Q. Public’s drivers license All objects have identity and are distinguishable NOT objects n Person n Drivers license

Classes l l Describes a group of objects with similar properties (attributes), common behavior Classes l l Describes a group of objects with similar properties (attributes), common behavior (operations), common relationships to other classes, and common semantics Person u u u l J. Q. Public Joe Smith D. Q. Public Card u u u Credit card Drivers license Teller card

Class Diagrams Class diagram Instance diagram Person D. Q. Public 32 Class with attributes Class Diagrams Class diagram Instance diagram Person D. Q. Public 32 Class with attributes J. Q. Public 35 Objects with values Objects have an identity Do not explicitly list object identifiers SSN OK!

Examples Examples

Operations and Methods l Transformation that can be applied to or performed by an Operations and Methods l Transformation that can be applied to or performed by an object l May have arguments

Object Notation - Summary Object Notation - Summary

Associations l Conceptual connection between classes n n A credit card is issued-by a Associations l Conceptual connection between classes n n A credit card is issued-by a bank A person works-for a company Class diagrams Person J. Q. Public 35 Company Works-for 8 Michigan State Univ Instance diagram

Associations are Bi-directional l There is no direction implied in an association (Rumbaugh - Associations are Bi-directional l There is no direction implied in an association (Rumbaugh - OMT) Country name Person name Has-capital Is-issued City name Drivers-license lic. -number: integer

Associations Have Direction l Unified adds a direction indicator n Inconsistently used Country name Associations Have Direction l Unified adds a direction indicator n Inconsistently used Country name Person name Has-capital Is-issued City name Drivers-license lic. -number: integer

Multiplicity One person holds one credit card l One object can be related to Multiplicity One person holds one credit card l One object can be related to many objects through the same association One person can hold zero or more credit cards (* stands for many)

Multiplicity (Cont. ) One person can hold zero or more credit cards (0. . Multiplicity (Cont. ) One person can hold zero or more credit cards (0. . *) Each card has zero or one holder (0. . 1) Credit-Card Person Holds 8 123 456 789 J. Q. Public Person 35 D. Q. Public Holds 8 Credit-Card 111 222 333 32

Multiplicity (Cont. ) * • One person can hold zero or more credit cards Multiplicity (Cont. ) * • One person can hold zero or more credit cards (0. . *) • Each card has one holder (no indication or 1) • Each card has one or more authorized users (1. . *) • One person can be authorized to use zero or more cards • Driver’s License is optional (0. . 1) 1 Person name: String Holds 8 0. . * 3 Authorized 1. . * Holds 8 0. . 1 Explicit enumeration is also possible (2, 3, 2. . 5, etc. ) Credit-Card Credit-card-number: integer 0. . * Person Holds 8 123 456 789 J. Q. Public 35 Holds 8 3 Authorized Credit-Card 111 222 333 Driver’s License-number: integer 3 Authorized Person D. Q. Public 32 Holds 8 Credit-Card Authorized 3 111 222 333

Higher order associations l Ternary association n l Project, language, person Seldom needed (and Higher order associations l Ternary association n l Project, language, person Seldom needed (and should be avoided) Language Project C++ Compiler Person J. Q. Public 35 Language Project LISP Tic. Tac. Toe

Link Attributes l Associations can have properties the same way objects have properties How Link Attributes l Associations can have properties the same way objects have properties How to represent salary and job title? Use a link attribute!

Folding Link Attributes Why not this? Person name: String age: integer SSN: integer address: Folding Link Attributes Why not this? Person name: String age: integer SSN: integer address: String salary: integer job-title: String 0. . * Works-for 8 Company name: String address: String Salary and job title are properties of the job not the person In this case, a link attribute is the only solution

Another Approach Person name: String age: integer SSN: integer address: String Company name: String Another Approach Person name: String age: integer SSN: integer address: String Company name: String address: String Position Salary: integer Grade: integer Title: string *

Role Names l Attach names to the ends of an association to clarify its Role Names l Attach names to the ends of an association to clarify its meaning

Aggregation * l A special association, the is-part-of association n n A sentence is Aggregation * l A special association, the is-part-of association n n A sentence is part of a paragraph (a paragraph consists of sentences) A paragraph is part of a document (a document consists of paragraphs) Document 1. . * Paragraph Aggregation symbol 1. . * Sentence

Aggregation (Cont. ) l Often used in parts explosion Car 4 Wheel Body Gearbox Aggregation (Cont. ) l Often used in parts explosion Car 4 Wheel Body Gearbox 1. . * Door Engine 1. . * Hood Trunk Piston 1. . * Valve Crankshaft

Generalization and Inheritance l The is-a association n Cards have many properties in common Generalization and Inheritance l The is-a association n Cards have many properties in common Generalize the common properties to a separate class, the base-card Let all cards inherit from this class, all cards is-a base-card (plus possibly something more) Card height: integer width: integer thickness: integer id-number: integer issue() revoke() Drivers License ID Card Credit Card class: vehicle issued: date expires: date credit-limit: integer issued: date expire() validate() expire()

Example Owns City Based-In 0. . * name Located-In Pilot Works-for Airline 0. . Example Owns City Based-In 0. . * name Located-In Pilot Works-for Airline 0. . * 1. . * Offers name heat() clean() Certified-On Pilots 0. . * Airport name license Departs 0. . * Flight 0. . * date flight # cancel() delay() 0. . * Arrives Used-For Plane model serial # hours flown heat() refuel() clean() 30. . * Passenger name 0. . * Seat location Confirmed-for reserve()

Aggregation Versus Association l l l Can you use the phrase is-part-of or is-made-of Aggregation Versus Association l l l Can you use the phrase is-part-of or is-made-of Are operations automatically applied to the parts (for example, move) - aggregation Not clear what it should be……

Aggregation Versus Inheritance l l l Do not confuse the is-a relation (inheritance) with Aggregation Versus Inheritance l l l Do not confuse the is-a relation (inheritance) with the is-part-of relation (aggregation) Use inheritance for special cases of a general concept Use aggregation for parts explosion Minivan 4 Wheel Body Car Gearbox Engine Compact Jeep Roll Bar

Recursive Aggregates l A recursive aggregate contains (directly or indirectly) an instance of the Recursive Aggregates l A recursive aggregate contains (directly or indirectly) an instance of the same kind of aggregate

Object Modeling Summary l Classes n n n l Name Attributes Operations Associations n Object Modeling Summary l Classes n n n l Name Attributes Operations Associations n n Roles Link attributes l l Aggregation Inheritance

Object Modeling Approach Object Modeling Approach

Object Modeling Approach l Start with a problem statement n l High-level requirements Define Object Modeling Approach l Start with a problem statement n l High-level requirements Define object model n n n n Identify objects and classes Prepare data dictionary Identify associations and aggregations Identify attributes of objects and links Organize and simplify using inheritance Iterate and refine the model Group classes into modules

The Home Heating System Water Valve Water Pump Home Hot Water Controller Burner Fuel The Home Heating System Water Valve Water Pump Home Hot Water Controller Burner Fuel Valve 90 80 70 Fuel Off On 60 50 Control Panel Temp Sensor

Home Heating Requirements The purpose of the software for the Home Heating System is Home Heating Requirements The purpose of the software for the Home Heating System is to control the heating system that heats the rooms of a house. The software shall maintain the temperature of each room within a specified range by controlling the heat flow to individual rooms. l l l l The software shall control the heat in each room The room shall be heated when the temperature is 2 F below desired temp The room shall no longer be heated when the temperature is 2 F above desired temp The flow of heat to each room shall be individually controlled by opening and closing its water valve The valve shall be open when the room needs heat and closed otherwise The user shall set the desired temperature on thermostat The operator shall be able to turn the heating system on and off The furnace must not run when the system is off l l When the furnace is not running and a room needs heat, the software shall turn the furnace on To turn the furnace on the software shall follow these steps n open the fuel valve n turn the burner on The software shall turn the furnace off when heat is no longer needed in any room To turn the furnace off the software shall follow these steps n close fuel valve n turn burner off

Identify Object Classes Requirements Statements Extract Nouns Eliminate Spurious Classes Candidate Classes Water Pump Identify Object Classes Requirements Statements Extract Nouns Eliminate Spurious Classes Candidate Classes Water Pump Object Classes Controller operator Hot Water Burner Tentative Object Classes furnace house thermostat Home Heating System room heating system Fuel Valve Water Valve temperature desired temp Fuel on-off switch heat Home Temp Sensor Control Panel software range

Eliminate Bad Classes l Redundant classes n l l Classes with ill defined boundaries Eliminate Bad Classes l Redundant classes n l l Classes with ill defined boundaries Attributes n Things that describe individual objects Operations n l Classes we simply do not care about Vague classes n l Classes that represent the same thing with different words Irrelevant classes n l Roles n l Sequences of actions are often mistaken for classes The name of a class should reflect what it is, not the role it plays Implementation details n Save that for implementation

Eliminate Classes Redundant Irrelevant heating system Fuel user software Vague heat Attributes heat flow Eliminate Classes Redundant Irrelevant heating system Fuel user software Vague heat Attributes heat flow Hot Water desired temp house temperature home range Operations Roles None Implementation None Fuel Valve None Burner furnace Water Pump Home Heating System room thermostat operator Temp Sensor Controller on-off switch Control Panel Water Valve

Classes After Elimination Burner Fuel Valve Home Heating System Water Pump Room Thermostat Water Classes After Elimination Burner Fuel Valve Home Heating System Water Pump Room Thermostat Water Valve Furnace Temp Sensor Operator on-off switch Control Panel Controller

Prepare Data Dictionary l Water Tank n l The storage tank containing the water Prepare Data Dictionary l Water Tank n l The storage tank containing the water that circulates in the system. Pump-1 n The pumping water from the Water Tank to the radiators in the rooms

Possible Associations l l l Not much information from the prose requirements A lot Possible Associations l l l Not much information from the prose requirements A lot of information from the system design l l l A room consists of a thermometer and a radiator A radiator consists of a valve and a radiator element The home heating system consists of a furnace, rooms, a water pump, a control panel, and a controller The furnace consists of a fuel pump and a burner The control panel consists of an on-off switch and a thermostat The controller controls the fuel pump The controller controls the burner The controller controls the water pump The controller monitors the temperature in each room The controller opens and closes the valves in the rooms The operator sets the desired temperature The operator turns the system on and off The controller gets notified of the new desired temperature

Object Model Object Model

Object Model - Modified Home Heating System Control Panel Furnace On-Off Switch Pushes Burner Object Model - Modified Home Heating System Control Panel Furnace On-Off Switch Pushes Burner Thermostat Adjusts Runs Fuel Valve Opens/Closes Ignites 1. . * Room Water Pump 1. . * Temp Sensor Heats Water Valve Monitor Notifies 1. . * Operator Controller

Attributes Thermostat desired-temp On-Off switch setting Temp Sensor temperature Attributes Thermostat desired-temp On-Off switch setting Temp Sensor temperature

Final Object Model Home Heating System Control Panel Furnace On-Off Switch setting Pushes Burner Final Object Model Home Heating System Control Panel Furnace On-Off Switch setting Pushes Burner Thermostat desired-temp Adjusts Runs Fuel Valve Opens/Closes Ignites 1. . * Room Water Pump 1. . * Temp Sensor temperature Heats Water Valve Monitor Notifies 1. . * Operator Controller

Iterate the Model l Keep on doing this until you, your customer, and your Iterate the Model l Keep on doing this until you, your customer, and your engineers are happy with the model Iterate

Operation vs Method l l l Operation: specifies object behavior Service: represented by set Operation vs Method l l l Operation: specifies object behavior Service: represented by set of operations. Message: object requests execution of an opern. from another object by sending it mesg. Method: mesg is matched up with method defined by the class to which the receiving object belongs (or any of its superclasses) Operations of class are public services offered by class. Methods of its classes are the implementations of these operations.