1
Software Design
Lecture : 18
2
Relationships between Classes
Ø
Association –Discussed in Previous Lecture
Ø
Aggregation
Ø
Composition
Ø
Inheritance
3
Aggregation or “ has –a “
relationship
Ø
Specialized form of association ie Weak
Association.
Ø
Assembling a class from other classes.
Ø
Aggregation is a special type of relationship used
4
Aggregation
Ø
In an aggregation relationship, the child class
instance can outlive its parent class.
Ø
Child class can be a part of multiple parent
classes.
Ø
To represent an aggregation relationship, you
5
Example
6
Aggregation Example
7
Example
8
9
Example – Aggregation and
Multiplicity
10
Composition – Container and Contained classes
Ø
It’s a strong association.
Ø
It contain Objects that live and die together.
Ø
The composition aggregation relationship is just
another form of the aggregation relationship, but
11
Composition Continues....
Ø
Another important feature of composition
aggregation is that the part class can only be
related to one instance of the parent class