Not only Inheritance
Composition “has-a” (strong connection) |
Building has a room. Containing object owns it. Objects' lifecycles are tied (if we destroy the owner object, its members also will be destroyed with it) |
Aggregation “has-a” (medium connection) |
Сar and its wheels. We can take off the wheels, and they'll still exist. Doesn't involve owning. Lifecycles of the objects aren't tied: every one of them can exist independently of each other. |
Association objects “know” each other (weak connection) |
Mother and child. The difference with aggregation is only logical: whether one of the objects is part of other or not. |
Comments
Related