Types of Aggregation

Classifying Part-Whole Relationships

An important category of relationships (i.e., associations) have the form:

Object X is part of object Y

For example:

Engine X is part of car Y

These are called part-whole, meronymic, or partonomic relationships.

Philosophers classify part-whole relationships according to how they combine the following three properties:

C = configurational = parts have a functional/structural relationship to each other or whole

H = homogeneous = parts same kind as whole

I = invariance = parts can't be separated from the whole

For example, a sub-category of partonomic relationships are those that are configurational, non-homogeneous, and non-invariant (CHI). Thus, there is a total of eight possible categories of patonomic relationships. Six are common, and two are represented in UML.

Composition or Assembly/Component Aggregation (CHI)

An engine is part of a car.
A piston is part of an engine.

Aggregation or Container/Member Aggregation (CHI)

A car is part of a fleet of cars.

Other types of part-whole relationships

Mixture/Ingredient Aggregation (CHI)

Flour is a part of a loaf of bread.

Metal is part of a car.

Whole/Portion Aggregation (CHI)

A slice of bread is part of a loaf of bread.

Place/Region Aggregation (CHI)

California is part of the USA

Partnership/Partner (CHI)

Laurel is part of Laurel and Hardy

Part-Whole Relationships in UML

We can represent the categories of Part-Whole relationships using a UML class diagram:

UML has special notation for composition and aggregation:

Transitivity Problem

Assume we represent the relationship X is part of Y by:

X is part of Y

Assume:

X is part of Y and Y is part of Z

Can we infer:

X is part of Z

In other words, is the is part of relationship transitive?

Generally, transitivity fails unless both is part of relationships have the same CHI type as defined above.

For example, the first inference is valid, but not the second:

piston part of engine
engine part of car
piston part of car

engine part of car
car part of fleet
engine part of fleet

Non Part-Whole Relationships

Topological Inclusion

the customer is in the store

Classification Inclusion (is-a)

"Moby Dick" is a book

Attribution

Smith is 5 feet tall

Attachment

Feet are attached to legs

Ownership

Smith owns a bicycle

Programming Notes

The Composite Design Pattern

The Composite Design Pattern is used in both domain modeling and design to represent partonomic hierarchies.

Reference

James Odell; Six Different Kinds of Composition; Journal of Object-Oriented Programming Vol 5, No 8. January 1994.