Open minds leads to freedom

Communicating my thoughts on software development

Association or Aggregation?

Posted by rnaufal on June 7th, 2006

I’ve been discussing with my co-workers when we have to use Aggregation or Association in UML models. Martin Fowler in UML Distilled, 3rd Edition says aggregation is the part-of relationship. It’s like saying that a car has an engine and 4 wheels as its parts. But aggregation was included in UML to differentiate from association, because in pre-UML days people didn’t knowhow to differentiate them. But aggregation, as Fowler says, is meaningless. Jim Rumbaugh says “Think of aggregation as a modeling placebo”. Association is a way to notate a property in our classes, but you don’t manage the life cycle of the associated property, as the aggregation relationship do. The solid line between the classes define the way one instance of the associating class can execute methods (operations realizations) of the associated object. So, why to use aggregation?

Share and Enjoy:
  • Twitter
  • Digg
  • del.icio.us
  • Reddit
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Technorati
  • FriendFeed
  • Google Buzz
  • MySpace
  • Slashdot
  • http://dserodio.livejournal.com/ dserodio

    What about Composition?

    When you say you don’t manage the life cycle of the associated property, as the aggregation relationship do, don’t you mean Composition ? IIRC, the link where you manage the lifecycle of the linked object is Composition.

    It’d be interesting to note the differences between Association, Aggregation and Composition.

  • http://rnaufal.wordpress.com/ rnaufal

    Re: What about Composition?

    Yeah, you’re right. I think I’ve expressed myself a little bit confused.
    Association is a way to notate a property in a class, in UML we have a solid line connecting the two classes, this notify how an object of the associating class can execute methods of the associated object in runtime. Composition means you control the life cycle of the composed object, so if an order has suborders and if the order becomes destroyed, the suborders are destroyed too. All of them has different meanings and UML notations, but the same implementation.

  • http://bpfurtado.livejournal.com/ bpfurtado

    I personally use the aggregation notation in a sense to give a more important role to the side of the relation which holds the empty diamond. Drawing my UML sketches (the way I like more to use UML) I use it just like that, without any formal meaning, without worrying too much about it.

    The part-of meaning of it it’s just not that appealing to me.