Archyno
UMLReferencia de notación

Símbolos del diagrama de clases UML

Cada punta de flecha, rombo y línea discontinua que puede llevar un diagrama de clases, dibujada a escala de leyenda junto a su significado: la página que dejas abierta al comprobar un trazo.

6 min de lecturaUML 2.5.15 de 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.

04Preguntas frecuentes

¿Qué significan las flechas en un diagrama de clases UML?

Un triángulo hueco es generalización y uno discontinuo realización; un rombo relleno es composición y uno hueco agregación; una línea simple es una asociación y una flecha abierta discontinua una dependencia. La punta está siempre en el extremo más general o poseedor.

¿Qué diferencia hay entre rombo relleno y rombo hueco?

El rombo relleno es composición: la parte se borra con el todo y pertenece exactamente a un todo. El rombo hueco es agregación: la parte puede compartirse y sobrevive al todo. Más allá de esa lectura, la agregación no lleva semántica formal en UML 2.5.1.

¿Qué significan más, menos y almohadilla antes de un atributo?

Son marcadores de visibilidad: más es público, menos privado, almohadilla protegido y virgulilla de paquete. Su sitio es un diagrama de diseño cuyo tema es la estructura del código, y suelen omitirse en un modelo de dominio porque no dicen nada del negocio.

Todos los artículos