I have a hand, I have a car.
I have a hand - life time of hand is same as my life time. hand dies with me :) it is tightly coupled. Its composition
I have a car - my car remains even if I die. This is aggregation.
association: is a relationship between two classes. It is the basic way of relation between two classes.
aggregation and association are more specific way of relationship between classes.
aggregation: has a relationship. one class can exist without other class
composition: one class is tightly coupled with other class. Life time of the classes will be the same.
Example2:
university has a chancellor (association)
university have faculties (composition)
university can exist without chancellors
university cannot exist without faculties. if faculties dispose then university will not exist.
university composed of faculties
No comments:
Post a Comment