Composition:
Composition is an association in which an object is composed with other smaller objects. This part relationship with whole is called composition.
Composition is stronger relationship because
- Composed object becomes a part of the composer.
- Composed object cannot exist independently.
Representation:
Composition is represented by a line with filled diamond hand towards the composer.
Example:
- A chair’s body is made of up of different parts. They can not exist independently.
- A person is made up of different body parts. They can not exist independent of person.
Aggregation:
In aggregation an object is a collection of other objects, it is a relationship between containers and contained.
Aggregation is weak relationship, because
- Aggregate object is not a part of the container.
- Aggregate object can exist independently.
Representation:
Aggregation is represented by a line with unfilled-diamond head towards the container.
Example:
Relationship between room and its furniture because furniture can be shifted to another room, so can exist independent of a particular room.
No comments:
Post a Comment