DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2004

    composition versus aggregation : example

    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.


  2. #2
    Join Date
    Feb 2005
    Attached pls find word doc to help you (taken from UML for dummies, no offence minded)

    Attached Files Attached Files

  3. #3
    Join Date
    Nov 2004
    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

    eschew obfuscation

  4. #4
    Join Date
    Feb 2004
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.