Jump to content

Aggregation vs Composition

- - - - -

  • Please log in to reply
2 replies to this topic

#1
j.lai

j.lai

    Newbie

  • Members
  • PipPip
  • 21 posts
Hey,

I just finished learning about aggregation and composition in class diagrams the other day in class and I still don't fully understand what they mean or what they are used for. I was wondering if anyone here can give me a good explanation or what aggregation and composition is.

Thanks

#2
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
A car is composed of a bunch of items, a car lot aggregates cars.

#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
The way i've learned it, is:
Both are part-whole relations with a slight difference

Composition
Let's take an 'order' which consists of 'orderLines'. orderLines can't exist on their own, it's always part of an order. So if the order is gone, so are the lines.
You can't have the parts without having the whole.

Aggregation
Let's take a 'book' which consists of 'pages'. A page can exist on its own and doesn't need a book to "live".
The part can exist on its own, without needing the whole.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users