Archyno
UMLRéférence de notation

Symboles du diagramme de classes UML

Chaque pointe de flèche, losange et pointillé qu'un diagramme de classes peut porter, tracé à l'échelle d'une légende à côté de son sens - la page à garder ouverte pour vérifier un tracé.

6 min de lectureUML 2.5.15 sur 28

1..*0..*10..*«abstract»AbstractOrderOrder- id: UUID- total: Money«interface»PrintableOrderLineTagCustomerPriceService
Every relationship kind a class diagram can carry, on one diagram, so the lines can be compared directly.

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.

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.

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.

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

  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.
  3. 03Filled diamond means deleted with the whole; hollow means shared and surviving.
  4. 04A blank multiplicity means unspecified, not one - it is a gap in the diagram.
  5. 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.

04Questions fréquentes

Que signifient les flèches d'un diagramme de classes UML ?

Un triangle creux est une généralisation et un triangle en pointillés une réalisation ; un losange plein est une composition et un losange creux une agrégation ; un trait simple est une association et une flèche ouverte en pointillés une dépendance. La pointe est toujours du côté le plus général ou possédant.

Quelle différence entre losange plein et losange creux ?

Le losange plein est la composition : la partie est supprimée avec le tout et appartient à exactement un tout. Le losange creux est l'agrégation : la partie peut être partagée et survit au tout. Au-delà de cette lecture, l'agrégation ne porte aucune sémantique formelle en UML 2.5.1.

Que signifient plus, moins et dièse devant un attribut ?

Ce sont des marqueurs de visibilité : plus pour public, moins pour privé, dièse pour protégé et tilde pour paquetage. Ils ont leur place sur un diagramme de conception, dont le sujet est la structure du code, et s'omettent en général sur un modèle de domaine.

Tous les articles