Discussing Object relations
Before we start our discussion on OOP, first we should understand relationships. In the real world, objects have relationships between them and hierarchies as well. There are the following types of relationships in object-oriented programming:
- Association: Association represents a relationship between objects in a manner that all objects have their own life cycle. In association, there is no owner of these objects. For example, a person in a meeting. Here, the person and the meeting are independent; there is no parent of them. A person can have multiple meetings and a meeting can combine multiple persons. The meeting and persons are both independently initialized and destroyed.
Note
Aggregation and composition are both types of association.
- Aggregation: Aggregation is a specialized form of association. Similar to association, objects have their own life cycle in aggregations, but it involves ownership that means a child object cannot belong to another parent object...