Object associations are an important feature of OOP. Relationships exist between objects in the real world, and, in OOP, an association allows us to define a has-a relationship; for example, a bicycle has a rider or a cat has a nose.
The types of has-a relationship are as follows:
- Association: An association is used to describe a relationship between objects so that there is no ownership described, for example, the relationship between a car and a person. The car and person have a relationship described, such as a driver. A person can drive multiple cars and a car can be driven by multiple people.
- Aggregation: An aggregation is a specialized form of association. Similar to associations, objects have their own life cycle in aggregations, ...