Archyno
UMLFoundations

Which UML diagram to use

All fourteen UML diagram types side by side, sorted by the question each one answers - so you can pick in thirty seconds rather than drawing the wrong diagram for an hour.

9 min readUML 2.5.13 of 35

What types exist,and how do they relate?Who uses it,and what for?What happens,in what order?What runswhere?Class diagramUse case diagramSequence diagramDeployment diagram
The four questions that account for most real diagrams, and the diagram each one wants.

01Start from the question, not the catalogue

Fourteen diagram types is a menu, and a menu is the wrong tool when you already know what you want to say. The reliable way in is to write down the question in one sentence and let the sentence pick the diagram. Almost every real question maps onto one of four.

ElementNotationWhat it means
What is it made of?ClassTypes, their attributes and how they relate. The class diagram is the default answer to any structural question and the one whose notation the rest borrow.
Who wants what from it?Use caseActors, goals and the system boundary. A use case diagram is a scope agreement, not a design.
What happens, in what order?SequenceParticipants and the messages between them, top to bottom. Reach for a sequence diagram when the order is the thing that is hard.
What runs where?DeploymentNodes, artifacts and the paths between them. The deployment diagram is what an infrastructure or security review actually needs.

The four questions that cover most work.

02The seven structure diagrams

A structure diagram shows what the system is made of, and nothing in it changes over time. All seven reuse class-diagram notation, so the cost of the sixth is far lower than the cost of the first.

ElementNotationWhat it means
ClassEverydayTypes, attributes, operations and relationships. The one to learn first and the one you will draw most.
ObjectOccasionalOne snapshot of real instances. An object diagram is how you show that a confusing class diagram does in fact hold together.
ComponentCommonDeployable units and the interfaces they provide and require. The component diagram is the closest UML gets to an architecture picture.
DeploymentCommonNodes, artifacts, and which artifact is deployed onto which node.
PackageOccasionalNamespaces and the dependencies between them. A package diagram is how a cycle between modules becomes visible.
Composite structureRareThe internals of one classifier: parts, ports and connectors. Useful in embedded and systems work, rarely elsewhere.
ProfileRareHow UML itself is extended - stereotypes and tagged values. You read a profile diagram far more often than you draw one.

03The seven behaviour diagrams

A behaviour diagram shows what happens, in what order and under what conditions. If your question has a when in it, you are here. Four of the seven are interaction diagrams, which differ mostly in what they put on which axis.

ElementNotationWhat it means
Use caseCommonActors, goals and scope. Deliberately says nothing about how.
ActivityEverydaySteps, branches, concurrency and responsibility. The activity diagramis UML's flowchart, with real semantics attached.
State machineCommonThe lifecycle of one object: states, events and transitions. A state machine earns its place the moment a status column exists.
SequenceEverydayMessages between participants, ordered down the page.
CommunicationOccasionalThe same interaction drawn as a network, with numbered messages. A communication diagram shows who talks to whom rather than when.
TimingRareState against a time axis. A timing diagram is for when the deadline itself is the requirement.
Interaction overviewRareAn activity diagram whose nodes are whole interactions - the index page for a set of sequence diagrams.

04The four that carry the load

Most teams draw four types and read a fifth. That is not a failure of ambition - it is what happens when every diagram has to be kept true. The other ten are worth being able to read when you meet one, which is a much smaller investment than being able to draw one cold.

Reach for it when

  • Class - the domain, once, kept current. The diagram most likely to still be true a year later.
  • Sequence - the one or two flows that are genuinely hard to explain in a paragraph.
  • Activity - a process crossing teams, where the swimlane is the whole point.
  • Deployment - any system whose infrastructure is not obvious from the repository.

Reach for something else when

  • Composite structure, unless you are doing embedded or systems engineering.
  • Timing, unless a deadline in milliseconds is part of the requirement.
  • Interaction overview, unless you already have several sequence diagrams to index.
  • Profile, unless you are extending UML itself rather than using it.

If you are learning rather than choosing, the order is the same: class first, because six of the structure diagrams reuse its notation; then sequence, because it is the one people ask for by name; then activity and use case, which are cheap once you can read a guard. The symbol reference covers the vocabulary all of them share.

05When the answer is not UML at all

Three questions look like UML questions and are not. Reaching for the wrong notation costs more than reaching for the wrong diagram, because the audience cannot read it either.

ElementNotationWhat it means
A database schemaERUse an ER diagram in crow's foot notation. Tables and keys are not classes and operations.
A business processBPMNUse BPMN when business analysts are the audience or the model is destined for an engine. An activity diagram is the right answer only when the audience is engineers.
An enterprise landscapeArchiMateUse ArchiMate when the subject spans business, application and technology. UML has no vocabulary for a business capability.

06What to remember

In one line each

  1. 01Write the question in one sentence first. The sentence picks the diagram; the catalogue never does.
  2. 02Structure diagrams answer what it is made of; behaviour diagrams answer what happens. A when in the question means behaviour.
  3. 03Four types carry most real work: class, sequence, activity and deployment.
  4. 04Activity is about work and responsibility; sequence is about messages and their order.
  5. 05If the subject is a schema, a business process or an enterprise landscape, the answer is ER, BPMN or ArchiMate rather than UML.

07Common questions

Which UML diagram is most used in practice?

The class diagram, by a wide margin, followed by the sequence diagram. Between them they cover most design conversations: what the system is made of, and what happens when it runs. Use case and activity diagrams come next, usually in requirements work rather than design.

Which UML diagram shows the flow of a process?

The activity diagram. It has actions, decisions with guards, forks for concurrency and swimlanes for responsibility, which is exactly the vocabulary a process needs. Use a sequence diagram instead when the interesting part is which participant sends which message.

Should I use an activity diagram or a sequence diagram?

Ask what the diagram is about. If it is about the steps of a process and who is responsible for each, use an activity diagram. If it is about the messages exchanged between specific participants and their order, use a sequence diagram. Activity is about work; sequence is about conversation.

Which UML diagram shows the database structure?

None of them directly. A class diagram is the closest, and is often used for a domain model, but it describes types and behaviour rather than tables and keys. For a schema, use an entity relationship diagram in crow's foot notation, which was designed for exactly that.

How many UML diagrams does one system need?

Usually three or four, not fourteen. A class diagram for the domain, a sequence diagram for the one or two flows that are hard, and a deployment diagram if the infrastructure is not obvious. Every additional diagram is another artifact somebody has to keep true.

All articles