1
play

1 Characteristics of Objects Identity The Class Diagrams Discrete - PDF document

Outline Conceptual modeling Conceptual Modeling The goal of conceptual modeling The OO solution The object model (conceptual) Syntax and semantics A Short Discussion Object modeling


  1. ✦ ✡ ✿ ❀ ✥ ❀ ✿ ☛ Outline ● Conceptual modeling Conceptual Modeling ■ The goal of conceptual modeling ● The OO solution ● The object model (conceptual) ■ Syntax and semantics A Short Discussion ● Object modeling approach ■ Home Heating System 06-Modeling 1 2 06-Modeling Conceptual Modeling The OO Solution ● Early modeling to understand the problem ● The OO model closely resembles the problem ● Conducted in cooperation with the customer domain ■ Domain experts ■ Base your model on the objects in the problem domain ◆ Domain engineers ● Iteratively refine the high-level model until you ● No real problem analysis if the customer is not involved have an implementation ● Power of OO ■ Attempt to avoid big conceptual jumps during the ■ It is simple and people can quickly participate effectively development process 3 4 06-Modeling 06-Modeling Objects Attributes and Operations Person class Person objects Attributes name age abstracts to height weight Operations move change-job Card objects Card class Attributes State of Michigan State of Michigan height Drivers License Drivers License VISA VISA width ✷✎✸✎✹✆✸✎✻✂✼✎✽✂✾ id-number ✙✎✚✎✛✆✚✎✜✂✢✎✣✂✤ ❆✩✳ ✴✎✵✎✲✮❁✓❂✎✶ Operations ✧✩★ ✪✎✫✎✬✮✭✓✯✎✰ �✂✁☎✄✆✁✂✝✂✞☎✟✂✠ ✷✂✸✎✹✺✸✂✻✂✼✎✽✎✾ ✱☎✲✎✳ ✴☎✵✎✳ ✶✎✲ ✱☎✲✎✳ ✴☎✵✎✳ ✶☎✲ ☞☎✌✎✍✑✏✓✒✎✔☎✕✗✖✎✖☎✕✂✕✎✔☎✔✗✘✎✘✂✖ issue ✴☎✵✂✲✑❁✂❂✎✶✎❃✗❄☎❄✎❃✂❃☎✶✎✶✗❅☎❅✂❄ change 5 06-Modeling 1

  2. Characteristics of Objects ● Identity The Class Diagrams ■ Discrete and distinguishable entities ● Classification ■ Abstract entities with the same structure (attributes) and behavior (operations) into classes ● Polymorphism ■ The same operation may behave differently on different classes ● Inheritance ■ Sharing of attributes and operations based on a hierarchical relationship 06-Modeling 8 7 06-Modeling Objects Classes ● Something that makes sense in the application context ● Describes a group of objects with similar properties (attributes), (application domain) common behavior (operations), common relationships to other ■ J.Q. Public classes, and common semantics ■ Joe’s Homework Assignment 1 ● Person ■ J. Q. Public’s drivers license ◆ J. Q. Public ◆ Joe Smith ● All objects have identity and are distinguishable ◆ D. Q. Public ● NOT objects ● Card ■ Person ◆ Credit card ◆ Drivers license ■ Drivers license ◆ Teller card 9 10 06-Modeling 06-Modeling Class Diagrams Examples Class diagram Instance diagram Person Person Person Person name: String D. Q. Public J. Q. Public name: String age: integer 32 35 age: integer Card height: integer Class with attributes Objects with values weight: integer height: integer SSN: integer width: integer Person Objects have an identity thickness: integer person ID: integer Do not explicitly list id-number: integer name: String object identifiers age: integer SSN OK! 11 12 06-Modeling 06-Modeling 2

  3. ❈ ❉ ❇ ❊ ❈ Operations and Methods Object Notation - Summary ● Transformation that can be ● May have arguments Class name applied to or performed by an object attribute-1 : data-type-1 = default-value-1 attribute-2 : data-type-2 = default-value-2 attribute-3 : data-type-3 = default-value-3 Card Shape height: integer operation-1(argument-list-1) : result-type-1 height: integer width: integer width: integer operation-2(argument-list-2) : result-type-2 thickness: integer operation-3(argument-list-3) : result-type-3 rotate(angle: integer) id-number: integer move(x: integer, y: integer) issue() revoke() 13 14 06-Modeling 06-Modeling Associations Associations are Bi-directional ● There is no direction implied in an association ● Conceptual connection between classes ■ A credit card is issued-by a bank ■ A person works-for a company Country City Has-capital Issued-by name name Credit Card Bank Class diagrams Works-for Person Company Person Drivers-license Is-issued name lic.-number: integer Person Company Works-for Instance diagram J.Q. Public Michigan State Univ 35 15 16 06-Modeling 06-Modeling Associations Have Direction Multiplicity Person Credit-card One person holds one Holds ● Unified adds a direction indicator card-number: integer name: String credit card ■ Inconsistently used Country City Has-capital ● One object can be related to many objects name name through the same association Person Drivers-license Is-issued One person can hold zero Person Credit-card Holds 0..* name lic.-number: integer card-number: integer name: String or more credit cards (* stands for many) 17 18 06-Modeling 06-Modeling 3

  4. ◗ ● ❑ ❋ ❋ ❍ ❍ ▼ P ❖ ◆ ❏ Multiplicity (Cont.) Multiplicity (Cont.) * One person can hold zero or more credit cards (0..*) •One person can hold zero or more credit cards (0..*) Each card has zero or one holder (0..1) •Each card has one holder (no indication or 1) Explicit enumeration is also •Each card has one or more authorized users (1..*) •One person can be authorized to use zero or more cards possible (2, 3, 2..5, etc.) Person Credit-card 0..1 Holds 0..* •Driver’s License is optional (0..1) card-number: integer name: String Credit-Card 1 Holds 0..* Credit-card Person ■ Authorized ▲ Authorized Person 123 456 789 Credit-Card card-number: integer Holds name: String J. Q. Public 1..* 0..* 35 Holds Holds 123 456 789 ■ Authorized Person Credit-Card J. Q. Public Credit-Card Person Holds 0..1 111 222 333 35 Driver’s License ■ Authorized Holds D.Q. Public Person 111 222 333 License-number: integer Credit-Card 32 D. Q. Public Holds 32 ■ Authorized Credit-Card 111 222 333 111 222 333 19 20 06-Modeling 06-Modeling Higher order associations Link Attributes ● Ternary association Associations can have properties the same way objects have properties ● Project, language, person ■ 1..* 1..* Language Project Seldom needed (and should be avoided) ● Person How to represent 1..* Company name: String 0..* Works-for salary and job title? age: integer name: String Person SSN: integer address: String address: String Language Project C++ Compiler Person Company name: String 0..* Person Works-for age: integer name: String J. Q. Public SSN: integer address: String Use a link attribute! 35 address: String Language Project salary: integer LISP TicTacToe job-title: String 21 22 06-Modeling 06-Modeling Another Approach Folding Link Attributes Why not this? Person Person name: String name: String Company Company age: integer Salary and job title are age: integer 0..* Works-for SSN: integer name: String properties of the job not SSN: integer name: String address: String address: String address: String address: String salary: integer the person job-title: String Person Company Position * name: String 0..* Works-for 0..* age: integer name: String In this case, a link SSN: integer address: String address: String attribute is the only Salary:integer Grade:integer solution Title:string salary: integer job-title: String 23 24 06-Modeling 06-Modeling 4

  5. ❘ ❘ ❙ Role Names Aggregation * ● Attach names to the ends of an association to ● A special association, the is-part-of association clarify its meaning ■ A sentence is part of a paragraph (a paragraph consists of sentences) ■ A paragraph is part of a document (a document consists of paragraphs) Person Company name: String 0..* Works-for 0..* boss age: integer name: String 0..1 employee employer SSN: integer address: String address: String 1..* 1..* Document Paragraph Sentence 0..* worker Manages salary: integer job-title: String Aggregation symbol 25 26 06-Modeling 06-Modeling Aggregation (Cont.) Generalization and Inheritance ● Often used in parts explosion ● The is-a association Card ■ Cards have many height: integer width: integer properties in common thickness: integer Car ■ Generalize the common id-number: integer properties to a separate issue() revoke() class, the base-card 4 ■ Let all cards inherit from this class, all cards is-a Wheel Body Gearbox Engine base-card (plus possibly something more) Drivers License ID Card Credit Card 1..* 1..* 1..* issued: date credit-limit: integer class: vehicle Door Hood Trunk Piston Valve Crankshaft issued: date expires: date issued: date expires: date expire() validate() expire() 27 28 06-Modeling 06-Modeling Aggregation Versus Example Association Owns Pilot Works-for City Airline Based-In 0..* ● Can you use the phrase is-part-of or is-made-of name name name 0..* license ● Are operations automatically applied to the parts (for Located-In 1..* Offers Certified-On example, move) - aggregation Pilots 0..* 0..* ● Not clear what it should be…… Airport 0..* Plane Departs 0..* name 0..* Flight model serial # date heat() Arrives Used-For hours flown 0..* 0..* flight # clean() 0..* Company Division Department cancel() heat() delay() refuel() clean() Works-for 30..* Seat 0..* 0..* Passenger location name Person Confirmed-for reserve() 30 06-Modeling 5

Recommend


More recommend