Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Association, Aggregation, and Composition in OOP, Lecture notes of Object Oriented Analysis and Design

An overview of object-oriented programming (oop) relationships, specifically focusing on association, aggregation, and composition. Association represents a binary relationship between classes, illustrated using a solid line with an optional label. Aggregation is a special form of association, representing an ownership relationship between classes, and can be further divided into weak and strong aggregation. Weak aggregation models the relationship as 'has-a', while strong aggregation (also called composition or containment) indicates that the components exist only as part of the composite. Examples and figures to help illustrate these concepts.

Typology: Lecture notes

2021/2022

Uploaded on 02/03/2022

ammla
ammla 🇺🇸

4.5

(37)

275 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Dept. of CS & IT, Superior University
1
OO Relationships - Association,
Aggregation & Composition
[Note: Below material has been quoted from http://cs.joensuu.fi/pages/koles/oop/OOP_Development.ppt]
In Object Oriented world, if one class has to communicate with any other class (or classes), it has to
communicate by using one of the Object Oriented Relationships.
There are three (3) OO Relationships,
Inheritance or Generalization
Aggregation
o Weak
o Strong (Also called as Composition or Containment)
Association
Association
Association represents a general binary relationship that describes an activity between two classes.
An association is illustrated using a solid line between the two classes with an optional label that
describes the relationship.
Association may have navigability, i.e. direction of the relation. Each class involved in the relationship
may have a role name played by the class in the relationship.
Examples
A student taking a course is an association between the Student class and the Course class.
A faculty member teaching a course is an association between the Faculty class and the Course
class.
Figure: Class Diagram for Examples above
pf3
pf4

Partial preview of the text

Download Understanding Association, Aggregation, and Composition in OOP and more Lecture notes Object Oriented Analysis and Design in PDF only on Docsity!

OO Relationships - Association,

Aggregation & Composition

[ Note: Below material has been quoted from http://cs.joensuu.fi/pages/koles/oop/OOP_Development.ppt]

In Object Oriented world, if one class has to communicate with any other class (or classes), it has to communicate by using one of the Object Oriented Relationships.

There are three (3) OO Relationships,

 Inheritance or Generalization  Aggregation o Weak o Strong (Also called as Composition or Containment)  Association

Association

Association represents a general binary relationship that describes an activity between two classes.

An association is illustrated using a solid line between the two classes with an optional label that describes the relationship.

Association may have navigability, i.e. direction of the relation. Each class involved in the relationship may have a role name played by the class in the relationship.

Examples

 A student taking a course is an association between the Student class and the Course class.  A faculty member teaching a course is an association between the Faculty class and the Course class.

Figure : Class Diagram for Examples above

Self Association

Association may exist between objects of the same class. For example, a person may have supervisor.

Figure: Self Association

Strong Aggregation (Also called as Composition/Containment)

Composition is a stronger form of aggregation. In a composite object the components exists only as part of the composite.

Rules of Thumb

 The whole and parts have coincident lifetimes.  Both classes represent physical items.

Examples  An engine is a part a car.  A package is a part of a shipment.  Employee is a part of a team.

Figure: Strong Aggregation