Leer en español · Lire en français · Auf Deutsch lesen
Section 4.4 of 4.8 · Intermediate · 22 min read
The UML diagrams architects still use
Video lesson
5 min · narrated, with captionsListen only (audio)
Read the transcript
Boxes and lines are fine for structure, but some questions need more precision. In this lesson you'll learn the handful of diagrams from the Unified Modeling Language, or UML, that architects still use, and when they're worth the effort.
Musicians all over the world can read the same sheet music, because the notes and symbols mean the same thing everywhere. UML is a similar shared set of symbols for drawing software. A particular arrow means waits for an answer. Another means sends and carries on. You don't need to know all of it. Architects mostly use a handful of its drawings, each one only when its precision really helps.
UML is a general-purpose graphical language for describing the structure and behaviour of software. It was adopted as a standard by the Object Management Group in 1997, and the current version, 2.5.1, defines fourteen diagram types. Its reputation has changed. The early ambition to turn detailed models into code largely failed, and many teams now draw informal boxes and lines. Yet a few UML diagrams are still the best tools for questions about behaviour over time.
Martin Fowler describes three ways of using UML. As a sketch, it's informal and selective: only the important elements, often on a whiteboard, often thrown away. In his words, comprehensiveness is the enemy of comprehensibility. As a blueprint, it produces complete, precise models for someone else to implement. As a programming language, the model is detailed enough to be compiled into code. That survives only in some embedded and safety-critical niches. For architects, sketching is the default. Ask of each diagram: who will read it, and what decision does it support?
If architects keep only one UML diagram, it is usually the sequence diagram. It shows how participants interact over time for one scenario. Each participant across the top has a dashed lifeline, and time runs downwards. Here, the customer app places an order with the ordering service, which calls the payment provider and waits. A synchronous call has a solid line and a filled arrowhead. The reply comes back as a dashed line. This box is an alt fragment, showing alternatives. If the payment is authorised, the order is saved and confirmed. If it's declined, the app gets an error. Draw the failure scenarios too: that's where most architectural thinking happens. Finally, an order placed event goes to the topic as an asynchronous message: a solid line with an open arrowhead. The service doesn't wait. Getting these arrowheads right matters. Whether a service waits or moves on decides its latency, its failure modes and its coupling. The key spells them out.
A state machine diagram describes a lifecycle precisely. States are rounded rectangles, and each transition is labelled with an event, an optional guard condition, and an optional action. Here, an order starts pending payment, and becomes placed when payment is authorised. Then it moves through accepted, ready and out for delivery. It becomes delivered only when the hand-over code matches, and then the customer is notified. Orders can also be cancelled: when payment is declined, when the restaurant rejects them, or by support, with a refund. This lifecycle is shared by several services. Agreeing it in one diagram prevents bugs where one service thinks an order is cancelled while another dispatches a courier. And it answers questions text hides. Can an order be cancelled once it's out for delivery? Here, no.
Four more diagrams complete the set. A component diagram shows the interfaces each part provides and requires, which makes dependency direction visible. A deployment diagram shows nodes, such as a phone or a cluster, the artifacts deployed on them, and the communication paths between them. An activity diagram shows a workflow: who does each step, and what runs in parallel between a fork and a join. And a class diagram is best kept for a small domain model of the key business concepts. Drawing every class by hand is out of date within weeks.
UML is overkill when the audience doesn't know it and the question doesn't need it. But precision pays when misunderstanding is expensive, as at an interface between companies, where each side builds against the other's description. Regulated and safety-critical industries often require design documentation that auditors can trace. Lifecycle rules shared by several teams, like the order states, benefit from a notation that forces every transition to be stated. And when the people building a design can't easily ask its author, it needs to leave less to interpretation. One last tip: always add a key. Many readers don't know the notation.
The full section draws all six diagrams for the food-delivery platform, with the notation for each. Next, in Section four point five, we look at how to record the reasons behind decisions. See you there.
What you need to know
- UML is a general-purpose modelling language standardised by the OMG; the current version is UML 2.5.1 (December 2017), which defines fourteen diagram types in structure and behaviour families.
- Fowler distinguishes UML as sketch (selective, informal communication), blueprint (complete, precise models) and programming language (executable models); architects mostly sketch.
- Component diagrams show provided (ball) and required (socket) interfaces; deployment diagrams show nodes, artifacts and communication paths.
- Sequence diagrams show lifelines and activations; a filled arrowhead is a synchronous call, an open arrowhead on a solid line an asynchronous message, and a dashed line a reply; fragments such as alt, opt and loop add control flow.
- State machine diagrams describe lifecycles with states and transitions labelled event [guard] / action; activity diagrams describe workflows with decisions, forks, joins and swimlanes.
- Class diagrams are best kept for small domain models with associations, multiplicities and composition; full class diagrams should be generated, not hand-drawn.
- Precision is worth paying for at interfaces between organisations, in regulated and safety-critical work, for lifecycles shared by several teams and for distributed development.
What UML is, and where it stands today
The Unified Modeling Language (UML) is a general-purpose graphical language for describing the structure and behaviour of software. It grew out of the merger, at Rational Software in the mid-1990s, of the methods of Grady Booch, James Rumbaugh and Ivar Jacobson, and was adopted as a standard by the Object Management Group (OMG), an industry standards consortium, in 1997. UML 2.0 (2005) was a major revision. The current version is UML 2.5.1, published by the OMG in December 2017; the earlier UML 2.4.1 was also published by ISO as ISO/IEC 19505 (2012). The specification defines fourteen diagram types, divided into structure diagrams (such as class, component and deployment diagrams) and behaviour diagrams (such as activity, state machine and sequence diagrams).
UML's reputation has changed considerably. In the late 1990s and early 2000s it was promoted as the basis of model-driven development, in which detailed models would be transformed into code. That ambition largely failed outside specialist domains, and many teams associate UML with heavyweight processes and diagrams nobody read. When Marian Petre interviewed 50 professional software developers for a study presented at ICSE 2013, 35 said they did not use UML at all and most of the others used it selectively and informally; most teams draw informal boxes and lines rather than strict UML. Yet a handful of UML diagram types remain the best tools available for particular questions, especially questions about behaviour over time, and their notation is widely understood. An architect does not need all fourteen diagram types; they need perhaps six, used deliberately.
This section covers those six, each with a small example from the food-delivery platform used throughout this chapter. It assumes the C4 vocabulary from Section 4.3; the two combine well, with C4 for the structural overview and UML where precision about interfaces, interactions or states pays for itself.
Sketch, blueprint or programming language
Martin Fowler's UML Distilled (3rd edition, Addison-Wesley, 2003) and his essays of the same year distinguish three ways of using UML, a classification Steve Mellor arrived at independently. As a sketch, UML is used informally and selectively to communicate ideas: on a whiteboard before writing code (forward sketching) or to explain part of an existing system (reverse sketching). Only the important elements appear, the notation is followed loosely, and the diagram is often thrown away. Fowler's own summary is comprehensiveness is the enemy of comprehensibility
.
As a blueprint, UML is used to produce complete, precise models that someone else implements, or that are generated from existing code to document it in full; the point is completeness, and tools are usually needed. As a programming language, the UML model is detailed enough to be compiled into executable code, the goal of model-driven architecture (MDA). This mode survives in some embedded and safety-critical niches, often via specialised profiles and tools, but has not become mainstream.
For architects, sketch mode is the default and blueprint mode the exception. The useful question for each diagram is: who will read it, and what decision or understanding does it support? A sequence diagram sketched to agree how payment failures are handled is valuable even if it ignores half the notation. A full class model of a 200-class service, maintained by hand, is usually not.
Component diagrams: parts and their interfaces
A UML component diagram shows modular parts of a system and, above all, their interfaces. Its distinctive notation is the "ball and socket": a small circle on a stick (a provided interface, which the component offers) and a half-circle (a required interface, which it needs someone else to provide). When a ball sits in a socket, the two components are wired together through that interface. Dependencies are dashed arrows, optionally labelled with a stereotype such as «use».
This is exactly what architects care about when they want to show dependency direction and replaceability. In the example, the ordering component does not depend on the payment provider directly; it requires a PaymentPort interface, which a separate payment adapter implements. That is the dependency inversion and ports-and-adapters thinking of Chapter 3 made visible: swapping payment providers means writing a new adapter, not changing ordering. A C4 component diagram can show the same parts, but it does not distinguish provided from required interfaces.
Component diagram
Deployment diagrams: nodes and artifacts
A UML deployment diagram shows the physical or virtual infrastructure and what runs on it. Its elements are nodes, drawn as three-dimensional boxes, which are computational resources: a «device» such as a phone or server, or an «executionEnvironment» such as an operating system, a container runtime or a Kubernetes cluster, and nodes can be nested. Artifacts, drawn as rectangles with a document icon and the «artifact» stereotype, are the physical files deployed: a JAR, a container image, a mobile app bundle, a configuration file. Lines between nodes are communication paths, labelled with protocols.
Deployment diagrams are allocation views in the SEI's terms (Section 4.2). They answer the operations team's questions: where does each part run, how many copies, in which region, which network paths exist. C4's deployment diagram covers the same ground with less formal notation; either is fine as long as there is one per important environment and it shows replicas, managed services and network boundaries.
Deployment diagram
Sequence diagrams: who calls whom, in what order
If architects keep only one UML diagram, it is usually the sequence diagram. It shows how participants interact over time for one scenario. Participants appear across the top, each with a dashed vertical lifeline; time runs downwards. A thin rectangle on a lifeline, the activation (execution specification), shows when that participant is busy handling a message.
The arrowheads carry meaning. A synchronous message, where the sender waits for an answer, has a solid line and a filled arrowhead. A reply has a dashed line and an open arrowhead. An asynchronous message, where the sender carries on without waiting, has a solid line and an open arrowhead. Getting these right matters architecturally: whether the ordering service waits for the payment provider or publishes and moves on decides its latency, its failure modes and its coupling (see Section 0.6).
Combined fragments add control flow: a box labelled alt with guarded sections separated by a dashed line shows alternatives (if/else), opt shows an optional part, loop a repetition and par parallel sections. Use them sparingly; a sequence diagram with nested loops and alternatives is code drawn badly. Draw one diagram per important scenario, including the failure scenarios, which are where most of the architectural thinking happens.
Sequence diagram
State machine diagrams: lifecycles and rules
Many business objects have a lifecycle: an order, a payment, a subscription, an insurance claim. A state machine diagram describes it precisely. States are rounded rectangles; a filled circle marks the initial pseudo-state and a bullseye the final state. Transitions are arrows labelled event [guard] / action: the event that triggers the transition, an optional guard condition that must be true, and an optional action performed on the way. States can have internal behaviours such as entry / notify restaurant.
State machines are architectural more often than people expect. The order lifecycle below is shared by several services: ordering owns it, dispatch and notification react to its transitions, and support staff can trigger some of them. Agreeing on the states and the legal transitions, in one diagram, prevents a whole class of bugs in which one service thinks an order is cancelled while another dispatches a courier. The diagram also exposes questions that text hides: can an order be cancelled once it is out for delivery? (Here, no: there is no transition from that state to Cancelled.) Is a refund an action on a transition or a separate lifecycle?
State machine diagram
Activity diagrams: workflows and parallelism
An activity diagram is a flowchart with precise semantics. Rounded rectangles are actions; diamonds are decisions (with guards on the outgoing flows) and merges; thick bars are forks, which split one flow into parallel flows, and joins, which wait for all incoming flows before continuing. Partitions, often called swimlanes, show who or what performs each action. A loop must flow back through a merge diamond: two flows drawn straight into one action would mean that the action waits for both, like a join.
Architects use activity diagrams for business processes and workflows that span several parts of a system, especially where parallelism and responsibility matter. The example shows that food preparation and courier assignment run in parallel, that assignment loops until a courier accepts, and that hand-over waits for both. That raises an architectural question immediately: what if no courier accepts within twenty minutes while the food is ready? The diagram makes the gap visible; the answer might be a timeout transition, a compensation step, or a change to the order lifecycle. Long-running workflows of this kind are often implemented as sagas or orchestrated workflows, covered in Chapter 6.
Activity diagram
Class diagrams, used sparingly: the domain model
The class diagram is the best-known UML diagram and the one architects should use most sparingly. Drawing every class of a service by hand is the blueprint mode at its least useful: it is out of date within weeks and the code says the same thing more precisely. Where class diagrams earn their place is the domain model: a small diagram of the key business concepts, their attributes and their relationships, which developers, product managers and domain experts can discuss together. In domain-driven design terms (Chapter 5) it captures the ubiquitous language of one bounded context.
The essentials are few. A class box has a name, attributes and optionally operations. A plain line is an association, optionally named, with multiplicities at each end (1, 0..1, 0..*, 1..*). A filled diamond marks composition: the parts belong to exactly one whole and do not outlive it, as order lines belong to an order. A hollow triangle marks generalisation (inheritance) and a dashed line with an open arrowhead a dependency. Multiplicities carry real design decisions: Order 1 to 0..1 Delivery says an order has at most one delivery, which rules out splitting a large order between two couriers. If the business might want that, the diagram is where the question surfaces.
Class diagram of the domain model
The six diagrams at a glance
| Diagram | Answers | Key notation | Typical use by architects |
|---|---|---|---|
| Component | What are the parts and through which interfaces do they depend on each other? | Component boxes, provided (ball) and required (socket) interfaces, dependencies | Showing dependency direction and replaceable parts; ports and adapters |
| Deployment | Where does each part run, how many copies, connected how? | Nodes (3D boxes), artifacts, communication paths | Production and staging infrastructure, network zones |
| Sequence | In what order do participants interact for this scenario? | Lifelines, activations, sync and async messages, replies, fragments | Key runtime scenarios, especially failures, retries and integrations |
| State machine | Which states can this object be in, and what moves it between them? | States, initial and final states, transitions with event [guard] / action | Lifecycles shared between services: orders, payments, claims |
| Activity | What is the workflow, who does each step, what runs in parallel? | Actions, decisions, forks and joins, partitions | Business processes, long-running workflows, sagas |
| Class | What are the key concepts and how are they related? | Classes, associations, multiplicities, composition, generalisation | Small domain models; generated diagrams of code |
When UML is overkill, and when precision matters
UML is overkill when the audience does not know it and the question does not need it: a C4 context diagram communicates better to executives than a UML use case diagram, and a whiteboard sketch is the right tool for a design discussion that will be over in an hour. It is overkill when diagrams are maintained by hand that could be generated, and when strict notation is enforced in a sketch whose purpose is to explore. Fowler's observation that the precision added in UML 2 mostly serves blueprint and programming-language users, and burdens sketchers, still holds.
Precision pays when misunderstanding is expensive. Interfaces between companies are the clearest case: when the food-delivery company integrates with a payment provider or a large restaurant chain's ordering system, each side builds against the other's description and discovers mismatches only in testing or production. A precise sequence diagram of the payment flow, including timeouts, retries, idempotency keys and webhooks, attached to the interface specification, is cheap insurance. Regulated and safety-critical industries (medical devices, rail, aviation, automotive, some financial systems) often require design documentation that auditors can trace from requirements to implementation; formal UML or its systems-engineering relative SysML is common there. Concurrency and lifecycle rules shared by several teams, like the order states above, benefit from a notation that forces every transition to be stated. And outsourced or distributed development, where the people implementing a design cannot easily ask its author, needs descriptions that leave less to interpretation.
Questions people ask
Should our team learn UML at all?
Learn the notation essentials of the six diagrams in this section; it takes a few hours and gives the team a shared vocabulary for interfaces, interactions and lifecycles. There is little need to learn the other diagram types or the full specification unless you work in a domain that requires them.
How does UML relate to C4?
They are complementary. C4 provides a small set of abstractions and a hierarchy of structural diagrams; UML provides precise notations, especially for behaviour. Many teams use C4 for context, container and component views and UML for sequence, state and occasionally deployment diagrams.
Can I draw UML with text instead of a drawing tool?
Yes. PlantUML and Mermaid both generate sequence, state, class and activity diagrams from short text files that can live in version control. Section 4.7 shows examples.
Check your understanding
In a sequence diagram, how do you tell a synchronous call from an asynchronous message?
A synchronous call has a solid line with a filled arrowhead (the sender waits); an asynchronous message has a solid line with an open arrowhead (the sender continues). Replies are dashed lines with open arrowheads.
What does the label handedOver [code matches] / notify customer on a transition mean?
When the handedOver event occurs and the guard "code matches" is true, the transition fires and the action "notify customer" is performed.
Why should architects rarely hand-draw class diagrams of whole services?
They duplicate what the code states more precisely and go out of date quickly; small domain models are worth drawing, and full diagrams can be generated when needed.
Give two situations in which precise UML is worth the effort.
For example, interfaces between companies, regulated or safety-critical development, lifecycles shared by several teams, or outsourced development where implementers cannot easily ask the designers.
Sources and further reading
Have a question about this section? ArchitectBot, the course’s AI study assistant, answers from the course first.
Ask: “Which UML diagrams should I include in an interface specification for a partner company integrating with our API?”