Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Mikey Alleblas

+ Follow
since Jun 25, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mikey Alleblas

The way it seems to work to me is that an aggregation is purely conceptual. An Association links two classes which can be thought to be on the same level. In aggregation, it is just an association which identifies that the whole part (where the diamond is) is constituted of the parts (the other end) and this is how they associate. In programming this relationship, it doesn't seem much different to an association. I think an aggregation is redundant.

A good explanation from the book:
"The meaning of this simple form of aggregation is entirely conceptual. The open diamond distinguishes the 'whole' from the 'part', no more, no less. This means that simple aggregation does not change the meaning of navigation across the association between the whole and its parts, nor does it link the lifetimes of the whole and its parts."

A composition on the other hand is a strong association between the whole and its parts. When the whole class terminates, so do its parts. I think this wuold relate to programming as the instances of the "parts" classes being created within the "whole" object itself.
The book I got doesn't have composition in the part of the book where I got the defition for the aggregate.

A good explanation from the book:
"... in a composite aggreation, the whole is responsible for the disposition of its parts, which means that the composite must manage the creation and destruction of its parts. For example, when you create a 'Frame' in a windowing system, yuo must attach it to an enclosing 'Window'. Similarly, when you destroy the 'Window', the 'Window' object must in turn destroy its 'Frame' parts."

As for simple association, the book says:
"Use associations when yuo want to show structural relationships."
As for applications in code, I got no idea.

Do not take this information as being entirely correct, I am only learning it myself however I feel that I got it right since I was copying from the book .


Ps: The book I got for the curious is
The Unified Modeling Language User Guide
Grady Booch, James Rumbaugh and Ivar Jacobson
ISBN 0-201-57168-4
Was printed on recycled paper.,1144,0201571684,00.html

I first tried SAMS learn UML in 24 hours and do not recommend it at all. It is I feel, better suited for management who have no idea about UML and have no need to get in too deep, but want to get a basic understanding of proposed systems and such which have been modelled in the UML.

Other books worth considering
I never read it, but O'Reilly books have always been my favourite technical reference and preferred reading material of any sort for that matter.