posted 16 years ago
what Jesper said is correct.
But i interpreted it in this way.
Has-a relationships can be implemented by using both Composition and Aggregation. Here the difference is that in Composition, the lifetime of the contained object is controlled by the class which contains it.
That means in my example,
If i delete a car object, the engine object should also be deleted. (the engine alone cannot alone live without a car) (Another example, Human & heart). This is composition (Strong relationship).
But if i remove a department, employees can still live without that department. (Aggregation) (Another Example - Computer & Printer)
From Jesper's statements ("coupled to the implementation of the contained class"), I think aggregation and composition are not related to coupling.