Section 1/5Composition vs Aggregation
Composition vs Aggregation
Explore this concept
Aggregation
Aggregation is a weak "has-a" relationship. The container references objects that were created outside it and can exist independently. Destroying the container does not destroy the contained objects.
Composition vs Aggregation
- Composition (strong): Car creates Engine inside its constructor. Engine has no life outside Car.
- Aggregation (weak): Library stores Books that were created outside it. Books exist independently of the Library.