Sunday, 24 November 2013

What's the difference between Aggregation and Composition?

I've based this article heavily on information found in Wikipedia[1]. For more information, have a look there.
a family of links to different classes. For example: person-address
a specific kind of association between only two classes, parts can belong together but are things of themselves. For example: duck-pond, person-room
a specific kind of association between only two classes, but stronger than an aggregation, parent-child relationship, child cannot exist without the parent. For example: car-steeringwheel/house-room
a weak relationship, which indicates that one class depends on another because it uses it at some point in time. One class depends on another if the independent class is a parameter variable or local variable of a method of the dependent class. This is different from an association, where an attribute of the dependent class is an instance of the independent class. For example: AuthenticationService-User


In the Real World™ a car engine is part of a car, and if the car is scrapped (destroyed), so is the engine. In the realm of Software or Databases, it is often the case that an engine is suitable for more than one model car. So, matters are never black and white.[1]


[1] Wikipedia - Class diagram

No comments:

Post a Comment