posted 19 years ago
Here's how I address that topic in BJO (paraphrasing):
===
An association is a relationship between two classes A and B, implemented in code as follows:
one-to-one -- we provide A with a reference to an object of type B as an attribute (and vice versa, if we want the association to be bi-directional)
one-to-many -- if there is one instance of A for many instances of B, we equip A with a Collection of references to B as an attribute
many-to-many -- both A and B wind up with a Collection of the other as an attribute (if bi-directional)
===
Aggregation -- essentially an association that implies containment -- e.g., "has a", "is part of", "belongs to", etc. Aggregations are represented in code identically to associations, as discussed above.
===
Composition -- a strong form of aggregation in which the "contained" object ceases to exist if the "containing" object ceases to exist. Again, coded in the same way that associations/aggregations are coded, but extra work must be done programmatically to make sure that the contained object is "snuffed" when the containing object is.
===
I hope this helps ...