UML class diagram symbols
Every arrowhead, diamond and dash a class diagram can carry, drawn at legend scale beside what it means - the page to keep open while you check a mark.
6 min readUML 2.5.15 of 28
01The six relationships
| Element | Notation | What it means |
|---|---|---|
| Association | The two classes know about each other. The default, and the right answer far more often than the ones below it. | |
| Generalization | Hollow triangle at the parent. The child is a kind of the parent and can stand in wherever the parent is expected. | |
| Realization | Dashed, hollow triangle at the interface. The class provides what the interface declares, without inheriting state. | |
| Composition | Filled diamond at the whole. The part belongs to exactly one whole and is deleted with it. | |
| Aggregation | Hollow diamond at the whole. The part can be shared and outlives the whole. Carries no other formal meaning. | |
| Dependency | Dashed, open arrow. One class uses another without holding a reference to it - a parameter, a return type, a static call. |
The rule that makes these memorable is that the decorated end is the end that matters: the triangle points at the more general classifier, the diamond sits on the owning whole, and the open arrow points at the thing being used. If you can remember which end carries the mark, you can usually reconstruct the meaning.
02Inside the box: visibility, types and multiplicity
A class box is a name band with up to two compartments under it: attributes, then operations. Both are optional, and a box that is only a name is perfectly legal - usually the right thing on a diagram about relationships.
| Element | Notation | What it means |
|---|---|---|
| Public | + name: String | Visible to everything. What an interface's members always are. |
| Private | - id: UUID | Visible only inside the class. The default on most design diagrams. |
| Protected | # state: Status | Visible to the class and its subtypes. |
| Package | ~ cache: Map | Visible inside the owning package. Rare in practice. |
| Static | underlined | Belongs to the classifier rather than to an instance. |
| Abstract | italic | The class or operation has no implementation. Often written «abstract» instead, where italics would not survive a whiteboard. |
Multiplicity is written at the end of a relationship, and the syntax is small: 1 exactly one, 0..1 optional, * or 0..* any number including none, 1..* at least one, and 2..5 a genuine range. A missing multiplicity means unspecified rather than one, which is why leaving it blank is a gap and not a default.
03Guillemets, and the rest
Text in guillemets - «interface», «enumeration», «entity» - is a stereotype: an extension of the standard vocabulary that says what kind of thing this classifier is beyond "class". A handful are defined by UML itself; the rest come from a profile, which is the mechanism for inventing your own without leaving the language.
Two more marks are worth recognising. A note is a rectangle with a folded corner, attached by a plain dashed line, and it carries a constraint or a comment - anything in curly braces inside it, like {ordered} or {total >= 0}, is a constraint the model claims to hold. And a role name written near an association end names what that end is called from the other side, which is worth adding whenever the class name alone does not say it - manager and reports on the two ends of an association between Employee and Employee, for instance.
In one line each
- 01The decorated end is the end that matters: triangle at the parent, diamond at the whole, arrow at the used.
- 02Hollow triangle is generalization, dashed hollow triangle is realization.
- 03Filled diamond means deleted with the whole; hollow means shared and surviving.
- 04A blank multiplicity means unspecified, not one - it is a gap in the diagram.
- 05Guillemets mark a stereotype; the ones outside UML's own set come from a profile.
To see all of this on real models, read the worked examples; for the reasoning behind the marks rather than the marks themselves, the class diagram article.
04Common questions
What do the arrows in a UML class diagram mean?
A hollow triangle is generalization and a dashed one is realization; a filled diamond is composition and a hollow one aggregation; a plain line is an association and a dashed open arrow is a dependency. The head is at the more general or more owning end in every case.
What is the difference between a filled and a hollow diamond?
The filled diamond is composition, meaning the part is deleted with the whole and belongs to exactly one whole. The hollow diamond is aggregation, meaning the part can be shared and outlives the whole. Aggregation carries no formal semantics in UML 2.5.1 beyond that reading.
What do plus, minus and hash mean before an attribute?
They are visibility markers: plus is public, minus is private, hash is protected, and a tilde is package. They belong on a design-level diagram where the code structure is the subject, and are usually left off a domain model where they say nothing about the business.
Related reading