Skip to content
DiaGO

Aggregation

The hollow diamond - shared whole-part relationships where parts outlive the whole. And an honest note on why many modelers use it sparingly.

Aggregation is UML's notation for a shared whole-part relationship: a hollow (unfilled) diamond drawn at the whole end of an association line. It says "this class groups these parts" — a Team aggregates Players, a Playlist aggregates Songs — while making two promises that distinguish it from composition:

  1. Parts can be shared. A Player may belong to a club team and a national squad at the same time. A Song appears in thousands of playlists.
  2. Parts outlive the whole. Disband the team and the players are still people. Delete the playlist and the songs remain in the catalog.

If both promises are false — the part belongs to exactly one whole and dies with it — you are looking at composition, not aggregation. (If only the sharing promise fails, a plain association with a 0..1 or 1 multiplicity at the whole end says so more precisely.)

What it looks like

In a class diagram, the diamond sits at the whole, and multiplicities read as usual:

Playlist  0..*  <>--------  0..*  Song
(hollow diamond at the Playlist end)

In code, aggregation is nothing more than holding references to objects you did not create and will not destroy:

class Playlist {
  private songs: Song[] = [];
 
  add(song: Song): void {
    // The playlist stores a reference. It did not construct the Song
    // and removing it here does not delete the Song from the catalog.
    this.songs.push(song);
  }
 
  remove(song: Song): void {
    this.songs = this.songs.filter((s) => s.id !== song.id);
  }
}

Notice something important: this code is indistinguishable from a plain association. A Playlist holding Song references looks exactly like an Invoice holding a Customer reference. That observation is the key to the honest note below.

Aggregation vs. composition vs. plain association

Plain associationAggregation (hollow diamond)Composition (filled diamond)
OwnershipNone implied — just a structural linkWhole groups the parts, but does not own them exclusivelyWhole owns the parts exclusively
SharingUnconstrainedA part may belong to many wholes at onceA part belongs to at most one whole at a time
LifetimeIndependentParts routinely outlive the wholeDestroying the whole destroys (or reassigns) the parts
Formal weight in the UML specWell definedDeliberately looseGenuinely constrained

Composition earns the strong semantics: the filled diamond means real lifecycle rules, the kind that map to cascade deletes in ER modeling and to owned collections in code. Aggregation occupies the awkward middle.

The honest note: the spec barely defines it

This is formal UML semantics, not opinion: the UML specification states that the precise meaning of shared aggregation "varies by application area and modeler." In other words, the standard itself declines to say what the hollow diamond adds beyond a plain association. There is no mandated lifecycle rule, no sharing constraint you can rely on, no behavior a tool could check.

The industry convention that follows is equally well established: many experienced modelers either skip aggregation entirely — drawing a plain association with a good role name and multiplicity — or use it purely as a documentation signal meaning "think of this as a collection and its members." Martin Fowler famously advised treating it as if it were not there. That is informed convention, not dogma; teams that assign the diamond a specific, written-down meaning in their own modeling guidelines lose nothing by using it.

When it still earns its place

The hollow diamond does one thing genuinely well: it signals collection-membership intent at a glance, especially in domain models read by non-programmers. A product owner scanning a diagram of Team <>-- Player and League <>-- Team immediately reads "leagues contain teams, teams contain players" without parsing role names or multiplicities. For that audience, in a class diagram meant for conversation rather than code generation, the diamond is cheap and communicative.

Reach for it

  • You want to visually signal collection membership to non-technical readers
  • Parts genuinely outlive the whole and are shared, like songs across playlists
  • Your team has agreed in writing what the hollow diamond means in its diagrams

Avoid it

  • The part cannot exist without the whole, which calls for composition instead
  • You have spent more than a minute debating aggregation versus plain association
  • The diagram drives code or schema generation and needs precise semantics

Common mistakes

Agonizing over aggregation vs. association. This is the classic time sink, and the stakes are near zero: since the spec assigns aggregation almost no extra meaning, choosing wrong changes nothing a reader can rely on. When in doubt, draw a plain association and spend the saved minutes on multiplicities and role names, which carry real information.

Diamond on the part side. The diamond always attaches to the whole. A diamond at the Song end of Playlist — Song claims that songs aggregate playlists — backwards, and genuinely confusing to readers.

Using aggregation where composition is meant. If an OrderLine cannot exist without its Order, or a Room without its Building, the relationship is exclusive ownership with a shared fate. Drawing it hollow understates a constraint that actually matters — one of the few notation choices on this page with real consequences downstream, in database cascade rules and in which class is responsible for creating and destroying the parts.

Practice

Model a small library domain: Library, Member, Book, Loan, and ReadingList (members curate lists of books they recommend). Draw the class diagram and, for each relationship, choose plain association, aggregation, or composition — then justify each choice in one sentence, naming the sharing and lifetime facts that drove it. Hint: exactly one of these relationships is a defensible composition, at least one is a defensible aggregation, and at least one is a debate not worth having — say which, and why the debate is cheap to skip.