- Back to Home »
- Aggregation
Posted by : Sushanth
Thursday, 17 December 2015
Aggregation
Aggregation is a specialize form of Association where all object have their own lifecycle but there is a ownership like parent and child. Child object can not belong to another parent object at the same time. We can think of it as "has-a" relationship.
Aggregation is a specialize form of Association where all object have their own lifecycle but there is a ownership like parent and child. Child object can not belong to another parent object at the same time. We can think of it as "has-a" relationship.
Implementation details:
1.Typically we use pointer variables that point to an object that lives outside the scope of the aggregate class
2.Can use reference values that point to an object that lives outside the scope of the aggregate class
3.Not responsible for creating/destroying subclasses
1.Typically we use pointer variables that point to an object that lives outside the scope of the aggregate class
2.Can use reference values that point to an object that lives outside the scope of the aggregate class
3.Not responsible for creating/destroying subclasses
Example:
A single Employee can not belong to multiple Companies (legally!! ), but if we delete the Company, Employee object will not destroy.
A single Employee can not belong to multiple Companies (legally!! ), but if we delete the Company, Employee object will not destroy.