Hi everyone,
Can someone help me to make a very clear distinction between aggregation and composition in UML design ( to end up in java programming).
If you know a site where i can find good examples you can help.
Nice day to all.
Enssy
Printable View
Hi everyone,
Can someone help me to make a very clear distinction between aggregation and composition in UML design ( to end up in java programming).
If you know a site where i can find good examples you can help.
Nice day to all.
Enssy
Attached pls find word doc to help you (taken from UML for dummies, no offence minded)
bye
whale
In Norwegian we dont use so many latin words...
Aggregation is translated w. "piled up", "stuffed together"...
The difference between aggregation and composition
seems to be that in the case of an aggregate you
cannot "pull out parts of it" and use separately. In a
composition you have a modular construct where the
parts can be used in other compositions.
But I may be totally up the creek here, or... is it UML
:p
After checking my copy of Object-Oriented Software Engineering Using UML, Patterns and Java it seems that aggregation and composition aren't two distinct things.
There are two types of aggregation, [b]composition aggregation[b] and shared aggregation. Aggregation simply means something that is made up of parts. Composition Aggregation is one way that something can be made up of parts.
The example the book gives is as follows. Composition Aggregation is where the parts are dependent on the whole for their existence. It's an American book, so its example is American. For composition aggregation is uses States as an example. A County is always part of exactly one state, and it can't exist independantly of the State. A Township is always part of one County, and can't exist independantly of that County. (It's assuming Political boundaries are persistent).
Shared Aggregation is where the existence of the part is not dependant on the existence of the whole, and the part can exist seperately. As an example it uses Fire Engines and Fire Stations. The Fire Engine will be assigned to a Fire Station, but it is not bound to that Fire Station. It can be moved to different Fire Stations, or even be assigned to no Fire Station and still exist as an entity in it's own right.
After re-reading your post i'm wondering if you actually meant a distinction on the UML diagram rather than in concept, so i'll describe how to represent them in UML. I don't have a picture, so i'll have to describe it in words.
Aggregation is represented using a diamond attached to the whole, with a line going to the part. Composition Aggregation uses a filled diamond, and Shared Aggregation uses a hollow diamond.