Mathieu Tozer's Dev Blog

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




Aggregation Vs Composition

0 comments

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.


Cocoa Programming for Mac OS X

0 comments

Cocoa2



I got this book today! I've been getting through it - it's really good. Pg 96 already but I feel I am learning a lot. I like the way it's not all tutorials, not all theory. Not quite as heavy as the Apple documentation can sometimes be, and he sneaks in little boring bits here and there in between the fun stuff, so you barely notice.
And it wasn't prohibitively expensive either which is fantastic. 65 odd dollars at Borders.

Update:
I've used and understood about delegation from objects, and have a firm understanding about what happens in class structure in terms of where and how methods are called.
I'm regretting not stumbling upon this book earlier because it's really effective. Of course I won't know until I've finished it and find myself writing cocoa programs, using it as a reference, that it has been effective, but I'm confident!


+RSS | dev blog | Portfolio

About me

My status

Last posts

  • my del.icio.us
  • my flickr