Presentation is loading. Please wait.

Presentation is loading. Please wait.

Downloaded From: www.bsit.zxq.net.  We may want to reuse characteristics of more than one parent class Downloaded From: www.bsit.zxq.net.

Similar presentations


Presentation on theme: "Downloaded From: www.bsit.zxq.net.  We may want to reuse characteristics of more than one parent class Downloaded From: www.bsit.zxq.net."— Presentation transcript:

1 Downloaded From: www.bsit.zxq.net

2  We may want to reuse characteristics of more than one parent class Downloaded From: www.bsit.zxq.net

3 Mermaid

4 Downloaded From: www.bsit.zxq.net Mermaid WomanFish

5 Downloaded From: www.bsit.zxq.net Amphibious Vehicle

6 Downloaded From: www.bsit.zxq.net Amphibious Vehicle Land VehicleWater Vehicle Vehicle CarBoat

7  Increased complexity  Reduced understanding  Duplicate features Downloaded From: www.bsit.zxq.net

8  Which eat operation Mermaid inherits? Downloaded From: www.bsit.zxq.net Mermaid WomanFish eat … eat …

9 Downloaded From: www.bsit.zxq.net Mermaid WomanFish eat … eat … eat … Invoke eat operation of desired class

10  Which changeGear operation Amphibious Vehicle inherits? Downloaded From: www.bsit.zxq.net Amphibious Vehicle Land VehicleWater Vehicle Vehicle CarBoat changeGear

11  Some languages disallow diamond hierarchy  Others provide mechanism to ignore characteristics from one side Downloaded From: www.bsit.zxq.net

12  Objects in an object model interact with each other  Usually an object provides services to several other objects  An object keeps associations with other objects to delegate tasks Downloaded From: www.bsit.zxq.net

13  Class Association › Inheritance  Object Association › Simple Association › Composition › Aggregation Downloaded From: www.bsit.zxq.net

14  Is the weakest link between objects  Is a reference by which one object can interact with some other object  Is simply called as “association” Downloaded From: www.bsit.zxq.net

15  w.r.t navigation › One-way Association › Two-way Association  w.r.t number of objects › Binary Association › Ternary Association › N-ary Association Downloaded From: www.bsit.zxq.net

16  We can navigate along a single direction only  Denoted by an arrow towards the server object Downloaded From: www.bsit.zxq.net

17  Ali lives in a House Downloaded From: www.bsit.zxq.net AliHouse lives-in 1 1

18  Ali drives his Car Downloaded From: www.bsit.zxq.net AliCar drives * 1

19  We can navigate in both directions  Denoted by a line between the associated objects Downloaded From: www.bsit.zxq.net

20  Employee works for company  Company employs employees Downloaded From: www.bsit.zxq.net EmployeeCompany works-for 1 *

21  Yasir is a friend of Ali  Ali is a friend of Yasir Downloaded From: www.bsit.zxq.net YasirAli friend 1 1

22  Associates objects of exactly two classes  Denoted by a line, or an arrow between the associated objects Downloaded From: www.bsit.zxq.net

23  Association “works-for” associates objects of exactly two classes Downloaded From: www.bsit.zxq.net EmployeeCompany works-for 1 *

24  Association “drives” associates objects of exactly two classes Downloaded From: www.bsit.zxq.net AliCar drives * 1

25  Associates objects of exactly three classes  Denoted by a diamond with lines connected to associated objects Downloaded From: www.bsit.zxq.net

26  Objects of exactly three classes are associated Downloaded From: www.bsit.zxq.net StudentTeacher Course 1 * *

27  Objects of exactly three classes are associated Downloaded From: www.bsit.zxq.net ProjectLanguage Person * 1 *

28  An association between 3 or more classes  Practical examples are very rare Downloaded From: www.bsit.zxq.net

29  An object may be composed of other smaller objects  The relationship between the “part” objects and the “whole” object is known as Composition  Composition is represented by a line with a filled-diamond head towards the composer object Downloaded From: www.bsit.zxq.net

30 Ali Body Arm Head Leg 1 1 22

31 Downloaded From: www.bsit.zxq.net Chair SeatArm Back Leg 1 1 24

32  Composition is a stronger relationship, because › Composed object becomes a part of the composer › Composed object can’t exist independently Downloaded From: www.bsit.zxq.net

33  Ali is made up of different body parts  They can’t exist independent of Ali Downloaded From: www.bsit.zxq.net

34  Chair’s body is made up of different parts  They can’t exist independently Downloaded From: www.bsit.zxq.net

35  An object may contain a collection (aggregate) of other objects  The relationship between the container and the contained object is called aggregation  Aggregation is represented by a line with unfilled-diamond head towards the container Downloaded From: www.bsit.zxq.net

36 Room Cupboard Bed ChairTable * 1 1 1

37 Downloaded From: www.bsit.zxq.net GardenPlant *

38  Aggregation is weaker relationship, because › Aggregate object is not a part of the container › Aggregate object can exist independently Downloaded From: www.bsit.zxq.net

39  Furniture is not an intrinsic part of room  Furniture can be shifted to another room, and so can exist independent of a particular room Downloaded From: www.bsit.zxq.net

40  A plant is not an intrinsic part of a garden  It can be planted in some other garden, and so can exist independent of a particular garden Downloaded From: www.bsit.zxq.net


Download ppt "Downloaded From: www.bsit.zxq.net.  We may want to reuse characteristics of more than one parent class Downloaded From: www.bsit.zxq.net."

Similar presentations


Ads by Google