As a rule of thumb:
In composition (Person, Heart, Hand), aggregated objects (Heart, Hand) will be destroyed as soon as Person is destroyed.
In aggregation (City, Tree, Car) aggregated objects (Tree, Car) will NOT be destroyed when City is destroyed.
The bottom line is, composition stresses on mutual existence, and in aggregation, this property is NOT required.
class Person { private Heart heart; private List<Hand> hands; } class City { private List<Tree> trees; private List<Car> cars }
Advertisements