UML-Klassendiagramm-Symbole
Jede Pfeilspitze, Raute und Strichlinie, die ein Klassendiagramm tragen kann, in Legendengrösse neben ihrer Bedeutung - die Seite, die man beim Prüfen einer Markierung offen hält.
6 Min. LesezeitUML 2.5.15 von 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.
04Häufige Fragen
Was bedeuten die Pfeile im UML-Klassendiagramm?
Ein hohles Dreieck ist Generalisierung, ein gestricheltes Realisierung; eine gefüllte Raute ist Komposition, eine hohle Aggregation; eine schlichte Linie ist eine Assoziation, ein gestrichelter offener Pfeil eine Abhängigkeit. Der Kopf sitzt stets am allgemeineren oder besitzenden Ende.
Was unterscheidet gefüllte und hohle Raute?
Die gefüllte Raute ist Komposition: der Teil wird mit dem Ganzen gelöscht und gehört genau einem Ganzen. Die hohle Raute ist Aggregation: der Teil kann geteilt werden und überdauert das Ganze. Über diese Lesart hinaus trägt Aggregation in UML 2.5.1 keine formale Semantik.
Was bedeuten Plus, Minus und Raute vor einem Attribut?
Es sind Sichtbarkeitszeichen: Plus ist public, Minus private, das Doppelkreuz protected und die Tilde package. Sie gehören auf ein Entwurfsdiagramm, dessen Thema die Codestruktur ist, und entfallen meist im Domänenmodell, weil sie über das Geschäft nichts aussagen.
Passend dazu