UML profile diagrams
How to extend UML itself. Stereotypes, tagged values, and the extension arrow - the mechanism behind every «entity», «service» and «microservice» you have ever seen on a diagram.
6 min readUML 2.5.115 of 15
01What it shows
A profile diagram is UML describing an extension to itself. It is the only diagram in the language whose subject is the language, which is why it feels different from the other thirteen and why most people never draw one.
You have almost certainly used the result. Every time you have seen «entity», «service», «controller», or «microservice» on a class box, you were looking at an applied stereotype. A profile diagram is where that stereotype is defined: what it is called, what it can be attached to, and what extra properties it carries.
02The notation
| Element | Notation | What it means |
|---|---|---|
| Metaclass | box, «metaclass» | An element of UML itself - Class, Component, Association. What you are extending. |
| Stereotype | box, «stereotype» | The new concept you are adding to the language. |
| Extension | Solid line, filledtriangle at the metaclass. "This stereotype may be applied to that kind of element." | |
| Tagged value | an attribute on the stereotype | An extra property that applying the stereotype gives you - slo: Duration. |
| Profile | package, «profile» | The package that groups a set of stereotypes so they can be applied together. |
| «apply» | From a package to a profile: everything in here may use those stereotypes. |
03When you actually need one
Be honest about the threshold. Using a stereotype needs no profile at all - «entity» on a box communicates perfectly well to a human reader without anything being formally defined. You need a profile diagram when the stereotype has to mean something to a machine.
That happens in three situations. When a tool must validate the model - refusing to apply «microservice» to an association, or requiring that every one of them declares an SLO. When code or documents are generated from the model, and the generator branches on the stereotype. And when a whole industry has agreed on a vocabulary: SysML, MARTE, SoaML and the like are all UML profiles, and they are the main reason the mechanism exists.
04Keeping a profile useful
Reach for it when
- A tool has to validate or generate from the stereotype, not just display it
- You need extra structured data on model elements - owner, SLO, classification
- Adopting a standard profile such as SysML that somebody else has already defined
- The same handful of domain concepts recur across many diagrams and teams
Reach for something else when
- One or two stereotypes used purely as visual labels - just write them
- The concepts you are adding already exist in ArchiMate or another language
- Nobody will maintain the profile after the person who wrote it moves on
- You are extending UML to avoid learning the part of UML that already covers it
A good profile is small. Five to ten stereotypes, each with an obvious meaning and at most a couple of tagged values, applied consistently, is worth far more than forty that nobody can remember. And every tagged value you add is a field somebody has to fill in on every element, forever - so make each one earn its place.
One practical warning about portability: profiles are the part of UML that travels worst between tools. Stereotype definitions survive an XMI round-trip much less reliably than plain model elements do, and tagged values often arrive as untyped strings or not at all. If your model has to move between tools, keep the profile as small as you can bear.
In one line each
- 01The only UML diagram whose subject is UML itself.
- 02A stereotype extends a metaclass; the arrow is a solid line with a FILLED triangle.
- 03Generalization's hollow triangle means something different and is the usual mistake.
- 04Tagged values are extra properties that applying the stereotype provides.
- 05You need a formal profile only when a tool must act on the stereotype.
- 06Keep profiles small - they are also the part of a model that exports least reliably.
Related reading