1 / 22

Object Modeling (2)

Object Modeling (2). Chapter 3 (2) Part 1: Modeling Concepts Object-Oriented Modeling and Design Byung-Hyun Ha ( bhha@pusan.ac.kr ). Lecture Outline. Introduction Links and associations Advanced link and association concepts Generalization and inheritance Remaining parts. Introduction.

jena
Download Presentation

Object Modeling (2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Modeling (2) Chapter 3 (2) Part 1: Modeling Concepts Object-Oriented Modeling and Design Byung-Hyun Ha (bhha@pusan.ac.kr)

  2. Lecture Outline • Introduction • Links and associations • Advanced link and association concepts • Generalization and inheritance • Remaining parts

  3. Introduction • Class and objects • A class is abstraction or specification of a group of similar objects • e.g. Person vs. Joe, Mary, … • e.g. Every instance of our Vector has x, y, and length(). Person (Person) Joe Smith 24 (Person) Mary Sharp 52 name: string age: integer • publicclass Vector { • doublex; • doubley; • double length() { • double len = Math.sqrt(x * x + y * y); • return len; • } • }

  4. Introduction • Association vs. links • An association is abstraction or specification of a group of similar links • e.g. Has-capital Has-capital Country City name name (Country) Canada Has-capital (City) Ottawa (Country) France Has-capital (City) Paris (Country) Senegal Has-capital (City) Dakar

  5. Introduction • Association vs. links (cont’) • e.g. Intersects Intersects Line Point 2+ name name

  6. Links and Associations (cont’) • Multiplicity specification • How many instances of one class may related to a single instance of an associated class • One or many • Optional • Numbers loves Playboy Girl loves Romanticist Girl loves 3-5 1+ Boy Girl

  7. Links and Associations • Multiplicity depends on problem • e.g. tax collection application • e.g. auto workers’ union • It exposes hidden assumption built into the model Works-for Person Company Works-for Person Company

  8. Advanced Link and Association Concepts • Role • One end of association • Role name • A name that uniquely identifies one end of an association employee employer Person Company Works-for owner User Directory container authorized user contents

  9. Advanced Link and Association Concepts • Role name • All role names on the far end of associations attached to a class must be unique • The role name is a derived attribute of the source class • Role name for n-ary association • Association of degree 3 or more cannot simply be traversed from one end to another as binary associations can Project Language Person

  10. Advanced Link and Association Concepts • Link attributes • Properties of a link in an association Accessible by File User access permission /etc/termcap (read) John Doe /etc/termcap (read-write) Mary Brown /usr/doe/.login (read-write) John Doe

  11. Advanced Link and Association Concepts • Link attributes for one-to-many association • e.g. works-for and manages Works-for Person Company name social security no. address name address boss salary job title worker Manages performance rating

  12. Advanced Link and Association Concepts • Folding link attributes • It is possible to fold link attributes for one-to-one and one-to-many associations into the class opposite the “one” site • How is it possible and which one is preferred? Works-for Person Company name social security no. address name address salary job title Works-for Person Company name social security no. address salary job title name address

  13. Advanced Link and Association Concepts • Link attributes for ternary association Team Pitcher Year wins losses W L Harry Eisenstat Cleveland Indians 1939 6 7 Harry Eisenstat Detroit Tigers 1939 2 2 Willis Hudlin Cleveland Indians 1939 9 10 Willis Hudlin Cleveland Indians 1940 2 1 Willis Hudlin Washington Senators 1940 1 2 Willis Hudlin St. Louis Browns 1940 0 1

  14. Advanced Link and Association Concepts • Modeling an associations as a class • Each link becomes one instance of the class • It is useful when links can participate in associations with other objects or when links are subject to operations Authorized on User Workstation Authorization priority privileges start session home directory Director

  15. Advanced Link and Association Concepts • Ordering • A special kind of constraint {ordered} Window Screen Visible-on

  16. Advanced Link and Association Concepts • Qualification • A qualified association relates two object classes and a qualifier • The qualifier distinguishes among the set of objects at the many end of an association Directory File Directory File file name

  17. Advanced Link and Association Concepts • Examples • Ticker symbol of company in stock exchange • Company and office Stock exchange Stock exchange ticker symbol lists lists Company ticker symbol Company organization officer Company Person office

  18. Advanced Link and Association Concepts • Aggregation • “Part-whole” or “a-part-of” relationship • Used for components and assembly • Existence of a part depends on existence of whole • Tightly coupled form of association extra semantics • Transitivity • If A is part of B and B is part of C, then A is part of C • Antisymmetric • If A is part of B, then B is not part of A • Propagation of properties • e.g. location of a door handle is obtained from the door; door obtains its properties from the car, … Document Paragraph Sentence

  19. Generalization and Inheritance • Generalization • The relationship between a class and one or more refined version of it • superclass and subclass • “is-a” relationship • Transitive • ancestor and descendant • An instance of a subclass is simultaneously an instance of all its ancestor classes Equipment name manufacturer weight cost … Pump Tank flow rate volume

  20. Generalization and Inheritance • Examples • Fig. 3.23 and 3.24 • Some guidelines • Do not nest subclasses too deeply • “An inheritance hierarchy that is two or three levels deep is certainly acceptable; ten levels deep is probably excessive; five or six levels may or may not proper” • Inheritance, generalization, and specialization • Different viewpoints of the same relationship • A subclass is a special case of its superclass • Don’t borrow a class using inheritance, when the new class is not really a special case of the original class!

  21. Remaining Parts • Grouping constructs • Module and sheet • A sample object model • Fig. 3.25: object model for window system • Practical tips • …

  22. Homework • HW7 • Exercise 3.6 (p. 50) • HW8: extend E3.6 a. Modify the class diagram in Figure E3.6 (p. 51) so as to handle unary minus and functions (e.g., sqrt(x) for calculating square root of x) with arbitrary number of arguments. b. Prepare an instance diagram for the class diagram you made for the expression -(B + sqrt(B*B – 4*A*C))/(4*A*A).

More Related