Association / Aggregation / Composition and inheritance
Association Relationship where all object have their own lifecycle and there is no owner. Ex: Airplane and passengers. No ownership between the objects and both have their own lifecycle. Both can create and delete independently
Aggregation Special form of Association where all object have their own lifecycle but there is ownership ( Has a relationship) and child object can not belongs to another parent object. Ex: Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy.
Composition Special form of Aggregation . Child object dose not have their lifecycle and if parent object deletes, all child object will also be deleted (ownership). Ex : Person and hands.
Inheritance : ”is” relationship An employee is a person
Association No ownership Own lifecycle Aggregation Ownership ( has a..) Composition Ownership (composed of ..) No Own lifecycle Inheritance Is relationship
Association An association is usually represented as a data field in the class.
Representing Aggregation/composition in Classes An aggregation / composition relationship is usually represented as a data field in the aggregated class.
Inheritance Inheritance models the is-an-extension-of relationship between two classes.
Borrowing Loans Name Loan Person Borrower Address