Aggregation : An association in which one class refers to collection or a another class. This is a part of a whole relationship where the phase can exist without the whole .
e.g.: A line item is whole and the products are the phases. If a line item is deleted then the products have not be deleted .
|
Composition : An association in which one class refers to another class or a collection. This is a part of a whole relationship where the phase cannot implement without the whole . If the whole is deleted then the parts are deleted. For example: An Order is a whole and the line items are the phase. If an order is removed then all the line items should be deleted as well.
|
Aggregations are not used to be circular.
|
In a garbage-collected language like Java, The whole has the responsibility of operating the garbage collector to prematurely collect the part by holding reference to it.
|