Archyno
UMLNotation reference

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.

11 min readUML 2.5.17 of 35

The short answer

  • The decorated end of a line is the end that carries the meaning: the triangle points at the parent, the diamond sits on the owning whole, the open arrow points at what is used.
  • A solid line with a hollow triangle is generalization; a dashed one is realization. The first inherits structure and behaviour, the second only promises the operations.
  • A multiplicity describes the class it is written next to, so 0..* beside Order reads as many orders - not as many customers.
  • On the boxes: italic name means abstract, guillemets mean a keyword or a stereotype, a leading slash means derived, and braces are a constraint the model claims holds.

01The six relationships#

ElementNotationWhat it means
AssociationThe two classes know about each other. The default, and the right answer far more often than the ones below it.
GeneralizationHollow triangle at the parent. The child is a kind of the parent and can stand in wherever the parent is expected.
RealizationDashed, hollow triangle at the interface. The class provides what the interface declares, without inheriting state.
CompositionFilled diamond at the whole. The part belongs to exactly one whole and is deleted with it.
AggregationHollow diamond at the whole. The part can be shared and outlives the whole. Carries no other formal meaning.
DependencyDashed, open arrow. One class uses another without holding a reference to it - a parameter, a return type, a static call.
A UML class diagram showing every relationship kind at once. Order generalizes from AbstractOrder, realizes the Printable interface, is composed of OrderLine, aggregates Tag, is associated with Customer, and depends on a PriceService.
Every relationship kind a class diagram can carry, on one diagram, so the lines can be compared directly.

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.

02The boxes themselves#

Half the marks on a class diagram are on the lines and the other half are on the boxes, and the second half is the half people skip. A rectangle with a name in it is a class; everything below changes what kind of thing that rectangle claims to be, and a reader who does not know the difference reads an interface as a class and wonders why it has no attributes.

ElementNotationWhat it means
ClassOrderA plain rectangle with an upright name. The default, and the only one of these that needs no marking at all.
Abstract classAbstractOrderItalic name. Cannot be instantiated - it exists to be generalized from. Written {abstract} under the name where italics will not survive, which on a whiteboard is always.
Interface«interface» PrintableA contract with operations and no state. Classes reach it by realization - the dashed line with the hollow triangle - never by generalization.
Enumeration«enumeration» StatusA fixed set of literals, listed one per line in the compartment below the name: DRAFT, PLACED, SHIPPED. No visibility markers - literals are always public.
Data type«dataType» MoneyA value with no identity: two instances holding the same numbers are the same thing. «primitive» is the same idea for the built-ins.
Active class‖ Scheduler ‖Double vertical bars down the sides. The object owns a thread of control rather than waiting to be called - a process, a daemon, a queue consumer.

The box forms. Everything but the first one is a keyword or a change of type style, which is why they are so easy to read straight past.

An interface has a second, smaller notation that costs no box at all: a lollipop - a circle on a stick - drawn on the classifier that provides it, and a matching socket, an open half-circle, on the one that needs it. Push the two together and you have the ball-and-socket that component diagrams are built from. It says exactly what the dashed triangle says, in a tenth of the space, and it is the right choice the moment a diagram has more than about three interfaces on it.

03Inside 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.

ElementNotationWhat it means
Public+ name: StringVisible to everything. What an interface's members always are.
Private- id: UUIDVisible only inside the class. The default on most design diagrams.
Protected# state: StatusVisible to the class and its subtypes.
Package~ cache: MapVisible inside the owning package. Rare in practice.
StaticunderlinedBelongs to the classifier rather than to an instance.
AbstractitalicThe 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.

An operation is written + place(customer: Customer, at: Instant): Order - visibility, name, parameters with their types, then the return type after a colon. Two decorations turn up often enough to recognise: a parameter can carry a direction, as in out receipt: Receipt, and an attribute can carry a default, as in - status: Status = DRAFT. Neither is required, and a domain model is usually better without either.

04The ends of a line: arrows, roles and qualifiers#

A relationship carries meaning at both ends, and almost everything a class diagram gets wrong in review is at an end rather than in the middle. The line says two classes are connected; the ends say who can reach whom, how many, in what order, and under what name.

ElementNotationWhat it means
NavigabilityAn open arrow at one end: this end can be reached from the other, and nothing is claimed about the way back. Order holds a Customer; whether a customer can list their orders is a separate question.
Not navigableA small cross on the end. Explicitly not reachable that way - which is a much stronger statement than leaving the end bare, and worth making on the one or two places in a model where it is a real design decision.
Role name+ placedByWhat this end is called from the other side. Essential the moment a class relates to itself - manager and reports on the two ends between Employee and Employee - and useful whenever the class name alone does not say what the reference is for.
Multiplicity0..*How many objects sit at this end for one at the other. Read it towards the end it is written on: 1 at Customer and 0..* at Order means one customer, any number of orders.
Property string{ordered}In braces beside a multiplicity. {ordered} means position is part of the meaning, {unique} that duplicates cannot occur - together they are the difference between a list, a set and a bag.
Qualifier[ isbn ]A small box on the source end holding a key. It turns a 0..* into a 0..1: a Library has many Books, but a Library qualified by ISBN has at most one.
Association class- - - EnrolmentA class attached to the middle of an association by a dashed line, holding the attributes that belong to the pairing rather than to either side - a grade, an enrolment date, a price at time of order.
N-ary associationA hollow diamond in the middle with three or more lines out of it. Legal, rare, and almost always clearer redrawn as a class with three associations - which is what a database would make of it anyway.

Everything that can be written at the end of a line. Read the multiplicity towards the end it sits on - that one convention causes more misread diagrams than the arrowheads do.

05Notes, constraints and derived members#

The last group of marks is the one that carries the rules a box-and-line drawing cannot express on its own. A class diagram is a structure, and half of what a domain expert knows is a condition on that structure - a total that can never be negative, a pair of relationships where exactly one may be filled in.

ElementNotationWhat it means
Note⎒ commentA rectangle with a folded corner, tied to whatever it is about by a plain dashed line. Free text: an assumption, an open question, a link to the ticket the class came from.
Constraint{total >= 0}Braces, anywhere the constraint applies - inside a note, beside an attribute, on an association end. A claim the model says holds at all times, in whatever language reads clearly; OCL if the model is going to be checked mechanically, English if it is going to be read.
Derived/ age: IntegerA leading slash. The value is computed from others rather than stored - which is precisely the flag a schema generator and a code reviewer both need, and exactly the one people leave off.
Read only{readOnly}Set at creation and never afterwards. On an association end it is the difference between a reference you may re-point and one you may not.
Xor{xor}Written on a dashed line drawn between two associations: exactly one of them may be filled in for any given object. An invoice goes to a person or to a company, never both.
Generalization set{complete, disjoint}Beside a group of generalizations sharing one parent. complete means the subtypes cover every case, disjoint that nothing can be two of them at once. The four combinations are four genuinely different models.

One convention outside this table is worth knowing because it looks like a class diagram and is not: an underlined name of the form order1: Order is an instance, and a diagram made of those is an object diagram - the same notation showing one moment rather than every possible moment. Underlining inside a class box means something else entirely, and that is the static marker from the compartment table above.

06Guillemets, 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.

Guillemets are doing two different jobs and the spec distinguishes them even though nothing on the page does. «interface» and «enumeration» are keywords: part of UML, fixed in meaning, and legal in any tool. «aggregate root» or «pii» are stereotypes: your own vocabulary, defined in a profile, meaningful only to a reader who has been told what they mean. Both are worth using. It is worth knowing which one you have just written, because the second kind needs a legend on the diagram and the first does not.

A stereotype can carry tagged values too - {owner = payments-team, retention = 7y} under a stereotyped class - which is how a model starts holding the metadata a spreadsheet was holding badly. That is the mechanism a profile exists to define.

In one line each

  1. 01The decorated end is the end that matters: triangle at the parent, diamond at the whole, arrow at the used.
  2. 02Hollow triangle is generalization, dashed hollow triangle is realization - solid line inherits, dashed line only promises.
  3. 03Filled diamond means deleted with the whole; hollow means shared and surviving.
  4. 04A multiplicity describes the class it is touching, so read it towards the end it sits on.
  5. 05A blank multiplicity means unspecified, not one - it is a gap in the diagram.
  6. 06A leading slash is derived, braces are a constraint, and an underlined name is an instance rather than a class.
  7. 07Guillemets mark either a UML keyword or your own stereotype; only the second kind needs explaining on the diagram.

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.

07Common 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.

What does a slash before an attribute name mean?

A leading slash marks the attribute as derived: its value is computed from other attributes or associations rather than stored. Writing /age on a Person that already holds a date of birth is what tells a schema generator not to create a column and a reviewer not to look for the code that keeps it in sync.

What is the difference between a UML keyword and a stereotype?

Both are written in guillemets and they are not the same thing. A keyword such as interface or enumeration is part of UML itself and means the same in every tool. A stereotype such as aggregate root is your own vocabulary, defined in a profile, and means nothing to a reader who has not been told - so it needs a legend on the diagram where a keyword does not.

In this series

Related reading

All articles