Design concept
Both are building (Has - A - Relationship).
Composition (strong)
- Object cannot exist without owner.
- Preferred over inheritance
- Makes code:
- easier to change
- easier to test
- less tightly coupled
class Car {
private Engine engine;
}
Aggregation (weak)
- Object can exist independently.
- More on communication use, to explain the relationship
class Team {
private Player player;
}