dev-blog

Sunday, January 16, 2005

UML 2.0: semantical difference between composition and aggregation

Associations are describing a set of tuples of typed instances.

In general there is no semantic difference between the instances paricipating in such a tuple. Very often though one of the instances is playing the special role of a whole whereous the others represent the parts of that whole. As an example take the association between companies and departments. Departments are part of a company. Such forms of whole-part associations are Aggregations and Compositions.

An Aggregation is adding semantic information to a general Association by defining which end is the whole and which is the part.
A Composition is an even stronger kind of aggregation. The instance that is composing the parts is responsible for the life-cycle of the parts i.e. a part can not live without the whole and a part can at a given time only be owned by one whole. (Nevertheless is it possible that the part can be passed to an other owner)

Aggregation and Composition are not represented sub types of a general Association in UML 2.0 as one could think at the first glance. Instead an attribute of an associations member properties of the type AggerationKind is controlling this aspect.

AggregationKind is an Enumeration with the following literals:
  • none
  • shared
  • composite

0 Comments:

Post a Comment

<< Home