Download presentation
Presentation is loading. Please wait.
Published byJudith Strickland Modified over 9 years ago
1
Object Modeling (2) Chapter 3 (2) Part 1: Modeling Concepts Object-Oriented Modeling and Design Byung-Hyun Ha (bhha@pusan.ac.kr)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 public class Vector { double x; double y; 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 Country name City name Has-capital (Country) Canada (City) Ottawa Has-capital (Country) France (City) Paris Has-capital (Country) Senegal (City) Dakar Has-capital
5
Introduction Association vs. links (cont’) e.g. Intersects Line name Point name Intersects 2+
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 PlayboyGirl loves RomanticistGirl loves BoyGirl loves 1+3-5
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 PersonCompany Works-for PersonCompany Works-for
8
Advanced Link and Association Concepts Role One end of association Role name A name that uniquely identifies one end of an association PersonCompany Works-for employeeemployer UserDirectory container contents owner authorized user
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 ProjectLanguage Person
10
Advanced Link and Association Concepts Link attributes Properties of a link in an association FileUser Accessible by 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 Person name social security no. address Company name address Works-for salary job title Manages worker boss 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? Person name social security no. address Company name address Works-for salary job title Person name social security no. address salary job title Company name address Works-for
13
Advanced Link and Association Concepts Link attributes for ternary association PitcherYear Team wins losses WL Harry EisenstatCleveland Indians193967 Harry EisenstatDetroit Tigers193922 Willis HudlinCleveland Indians1939910 Willis HudlinCleveland Indians194021 Willis HudlinWashington Senators194012 Willis HudlinSt. Louis Browns194001
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 UserWorkstation Authorized on Authorization priority privileges start session Director home directory
15
Advanced Link and Association Concepts Ordering A special kind of constraint WindowScreen Visible-on {ordered}
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 DirectoryFile DirectoryFile file name
17
Advanced Link and Association Concepts Examples Ticker symbol of company in stock exchange Company and office Stock exchange Company ticker symbol lists Stock exchange Company ticker symbol lists CompanyPerson office officerorganization
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, … DocumentParagraphSentence
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 PumpTank flow ratevolume …
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).
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.