The Artima Developer Community
Sponsored Link

Definition of Composition and Aggregation

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Definition of Composition and Aggregation

Posted by John Rivett-Carnac on 02 Dec 1998, 3:07 PM

> Bill,

> Why do you use the term composition, and not aggregation. It
> makes it confusing when different terminology is used to
> describe the same thing. I've seen aggregation used many
> times, but not composition.

Both composition and aggregation are described in Ivar Jacobson's book "Object Oriented Software Engineering", section 3.2. He says that "Composition" is to "structure an object in parts" and uses the example of a person being made up of a head, body, arms etc. while in "Aggregation" there is an additional object called the aggregate object which "represents" the others. In this case he uses the example of a man, woman and child making up a family - there is an aggregate "family" object. I find this distinction rather subtle and not easy to follow. Why do we not have a separate "person" object? He also says in ch 5.4 that composition can be used "as an alternative to inheritance for reusing code" while in ch 7.3.1 an object which is "composed of" other objects is ... "sometimes called an aggregate"! <:�(
I think the track which Bill Venners is following, in which aggregation and composition are to do with different degrees of visibility/ownership of objects, may be more useful. However, perhaps this is just using the same words to mean something quite different!
I look forward to seeing the "correct" and/or "accepted" definitions from Bill Venners.




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us