Mathieu Tozer's Dev Blog

Cocoa, the development of Words, and other software projects (including those dang assessment tasks).




Aggregation Vs Composition


E-mail this post



Remember me (?)



All personal information that you provide here will be governed by the Privacy Policy of Blogger.com. More...



I always loose which is aggregation and which is composition.
So I'm going to learn and remember it here once and for all.

Composition is where you have a number of objects that make up another object - you can't have a dog's legs and liver and tounge etc, without having the dog object. The objects are composed. And therefore, if we delete a dog object, we loose all the objects it is composed of - cascading delete. So we fill in the diamond to signiy that those objects are contained within that mother dog object.

On the other hand, we can have a set of objects, trees, for example, that when aggregated together can form a forest. We can still have a forest with no trees, and we can have a single tree. Trees can belong to other forests too.
So we DON'T fill in the diamond with aggregation.

The Diamond always goes on the side of the 'group' object.

So there, I've learnt a bit about class diagrams.


0 Responses to “Aggregation Vs Composition”

Leave a Reply

      Convert to boldConvert to italicConvert to link

 


+RSS | dev blog | Portfolio

About me

My status

Previous posts

  • my del.icio.us
  • my flickr