# Aggregation vs. Composition

**In short:** Aggregation and composition are UML ways to show that something is made of parts. Composition is strict: a part belongs to one whole. Aggregation is loose and adds little beyond a plain association.

## Explanation

Both notations draw a diamond on an association line (see UML Association). The diamond says "this end is the whole, the other end is its part." The diamond sits at the whole end.

**Composition** uses a filled diamond. It is also called composite aggregation. It is the strong form of whole-part.

- A part can belong to only one composition at a time.
- The whole is responsible for creating and deleting its parts.
- When the whole is destroyed, its parts are destroyed too, or they move to another whole. No part is left free-floating.

**Aggregation** uses a white (hollow) diamond. It is the weak form. It only loosely suggests whole-part. More than one whole may refer to the same part.

**The three kinds in the UML model.** UML describes how an association shares its parts with a property called AggregationKind. It has three values:

- None.
- Shared: more than one whole may refer to each part.
- Composite: a part cannot be shared between wholes.

UML leaves the precise interpretation open to local convention. A team should therefore agree on what its diamonds mean.

**Is aggregation worth using?** Experts are skeptical. One source says aggregation adds no meaning beyond a plain association. It cites a view that calls it a modeling placebo. Another source says it has no distinct semantics, though UML defines the term. Its advice is to skip aggregation and use composition when it fits.

## Example

A game model has a Board made of Squares. Each Square belongs to exactly one Board. If the software Board object is destroyed, its Square objects are destroyed with it. This is composition, so the diagram shows a filled diamond at the Board end.

Now take a model with Team and Player, where one player may appear in several teams. A modeler could mark this with a white diamond. Many would draw a plain association instead, because the white diamond adds no further meaning.

## Trade-offs

Composition gives a clear rule: one owner, and the owner controls creation and deletion. The cost is that it only fits parts that truly belong to a single whole.

Aggregation allows sharing, but its meaning is vague. Readers may interpret the white diamond differently, since UML leaves it to local convention. A plain association avoids that confusion.

Composition (filled diamond: Board and Square) and aggregation (hollow diamond: Team and Player).

```plantuml
@startuml
class Board
class Square
class Team
class Player
Board *-- Square
Team o-- Player
@enduml
```

## Checks

- Every filled diamond sits at the whole (composite) end of its association.
- No part is shown in more than one composition relationship at a time.
- For each composition, the whole is the one that creates and deletes its parts.
- If white diamonds are used, the document states what the team means by them.

## Related

- [UML Association](https://arc.fuet.ch/concepts/modeling-uml/association.md)
- [UML Class Diagram](https://arc.fuet.ch/concepts/modeling-uml/class-diagram.md)
- [UML Class Diagram Relationship](https://arc.fuet.ch/concepts/modeling-uml/class-diagram-relationships.md)
- [Unified Modeling Language (UML)](https://arc.fuet.ch/concepts/modeling-uml/uml-unified-modeling-language.md)
- [Common Class Diagram Modeling Mistakes](https://arc.fuet.ch/concepts/modeling-uml/common-class-diagram-modeling-mistakes.md)
- [UML Modeling Best Practice](https://arc.fuet.ch/concepts/modeling-uml/uml-modeling-best-practice.md)
- [UML Generalization and Specialization](https://arc.fuet.ch/concepts/modeling-uml/generalization-and-specialization.md)

## Sources

- [Aggregation And Composition](https://martinfowler.com/bliki/AggregationAndComposition.html) — martinfowler.com, accessed 2026-11-09
- [16.13 Composition Over Aggregation | Applying UML and Patterns: UML Class Diagrams | InformIT](https://www.informit.com/articles/article.aspx?p=1398623&seqNum=14) — informit.com, accessed 2026-11-09
- [AggregationKind Enumeration (Microsoft.VisualStudio.Uml.Classes) | Microsoft Learn](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/dd479569(v=vs.120)) — learn.microsoft.com, accessed 2026-11-09
