UML Wizard logo

Learn UML

A practical introduction to the Unified Modeling Language, covering every diagram type UML Wizard draws.

What is UML?

The Unified Modeling Language (UML) is a standard set of diagrams for describing software: what it is made of, how its parts talk to each other, and how it behaves. It is maintained by the Object Management Group (OMG); UML Wizard follows UML 2.5.1 notation.

UML diagrams fall into two families:

You don't need every diagram for every project. Draw the one that answers the question you have, and leave out the detail that doesn't help answer it: a diagram is a way of communicating, not a complete copy of the code.

Every example on this page comes from the OnlineShop sample project (samples/OnlineShop/OnlineShop.umlwiz). Open it alongside this page to explore the diagrams in UML Wizard.

Class diagrams

The question it answers: what kinds of things are in my system, what do they know and do, and how are they connected? Class diagrams are the most widely used UML diagram, and the one UML Wizard can turn into code.

Entity #id: Guid +validate(): bool «interface» IPayable +pay(amount: decimal): bool Customer -name: string -email: string +placeOrder(cart: Cart): Order Order -number: string -status: OrderStatus +total(): decimal +addLine(p: Product, qty: int) OrderLine -quantity: int -unitPrice: decimal places 1 0..* 1..*
Based on Ordering → Domain Model in the OnlineShop sample.

Classes

A class is a box with up to three compartments: its name, its attributes (the data it holds) and its operations (what it can do).

Two special kinds of class carry a stereotype in guillemets above the name:

You can write your own stereotype, such as «aggregate root» or «entity», to say what role a class plays.

In UML Wizard: use the Class, Abstract, Interface and Enum tools, then double-click a class to edit its name, stereotype, attributes and operations.

Relationships

RelationshipDrawn asMeansTool
AssociationSolid lineThe classes know about each other: “a Customer places Orders”.Association
Directed associationSolid line, open arrowheadOnly one side knows the other: the arrow points to the class that is referenced.Directed
AggregationSolid line, hollow diamond at the whole“Has a”: a whole groups parts that can also exist without it (a team and its players).Aggregation
CompositionSolid line, filled diamond at the whole“Is made of”: the parts belong to exactly one whole and live and die with it (an order and its lines).Composition
GeneralizationSolid line, hollow triangle at the general class“Is a kind of”: inheritance. A Customer is a kind of Entity.Inheritance
RealizationDashed line, hollow triangle at the interface“Implements”: the class provides the interface's operations.Realization
DependencyDashed line, open arrowhead“Uses”: a weaker, often temporary, link, e.g. a parameter type.Dependency
Association Directed Aggregation Composition Generalization Realization Dependency
Diamonds sit at the whole; triangles and arrowheads point to the class being specialized, implemented or used.

Multiplicity

The numbers at each end of an association say how many objects take part. Read them from the far side: “one Customer places 0..* Orders”, “an Order has 1..* OrderLines”.

MultiplicityMeans
1exactly one
0..1optional: none or one
* or 0..*any number, including none
1..*at least one
2..4a range

In UML Wizard: double-click a relationship to set its label and the multiplicity at each end.

Common mistakes

Sequence diagrams

The question it answers: for one scenario, who calls whom, and in what order? Sequence diagrams are ideal for explaining a single flow through the system, such as checking out.

customer shop : ShopController orders : OrderService checkout(cart) placeOrder(cart) order confirmation
Based on Ordering → Checkout Sequence. Time runs downwards.

Lifelines

Each participant is a lifeline: a head with a dashed line hanging below it. The head names an object as name : Type (shop : ShopController); either part may be left out. A stick figure is an actor, someone or something outside the system, such as the customer.

In UML Wizard: Lifeline and Actor add participants.

Messages

Messages are arrows between lifelines, read from top to bottom. The label is the call, usually with its arguments.

MessageDrawn asMeansTool
SynchronousSolid line, filled arrowheadA call: the sender waits for it to finish.Sync
AsynchronousSolid line, open arrowheadA signal: the sender carries on without waiting (an email, an event, a queue message).Async
ReplyDashed line, open arrowheadThe return from a synchronous call, labelled with what is returned.Reply
CreateDashed line to the head of a new lifeline, «create»The sender creates the receiver; its lifeline starts there.Create

Common mistakes

State machine diagrams

The question it answers: what states can one thing be in, and what moves it from one to the next? They suit anything with a lifecycle: an order, a document, a connection, a user account.

Created edit pay / capture() Paid [in stock] Shipped [out of stock] Backordered cancel Cancelled
Simplified from Ordering → Order Lifecycle.

States and pseudostates

Transitions

An arrow from one state to the next, labelled trigger [guard] / effect. All three parts are optional:

A transition can return to the state it left (a self-transition, like edit above): the event is handled but the state doesn't change.

In UML Wizard: the Initial, Final and choice tools add pseudostates; drag with the transition tool from one state to the next, or back onto the same state.

Common mistakes

Activity diagrams

The question it answers: what steps happen, in what order, with which decisions and which steps in parallel? Activity diagrams are UML's flowcharts, good for business processes and algorithms.

Review cart [logged in] [guest] Log in Charge payment Reserve stock Send confirmation
Based on Ordering → Checkout Process.

Nodes and flows

ElementDrawn asMeans
ActionRounded rectangleOne step of work. Name it with a verb: Charge payment.
Initial nodeFilled circleWhere the activity starts.
Activity finalCircle around a dotThe whole activity ends, even if other paths are still running.
DecisionDiamond, one flow in, several outExactly one outgoing flow is taken, chosen by its guard.
MergeDiamond, several flows in, one outAlternative paths come back together.
ForkBar, one flow in, several outThe outgoing flows run in parallel.
JoinBar, several flows in, one outWaits until all incoming flows have arrived.
Control flowArrow, with an optional guard such as [guest]What happens next.

In UML Wizard: use the action, Initial, Final, decision and Fork/Join tools, and connect them with Flow. Drag the corner handle of a fork/join bar to make it longer or vertical.

Common mistakes

Use case diagrams

The question it answers: who uses the system, and what can they do with it? Use case diagrams give a one-page overview of the requirements, readable by people who aren't developers.

Online Shop Browse catalogue Place order Apply coupon Pay «extend» «include» Customer Member Payment Provider
Simplified from Requirements → Shop Use Cases.

Elements

Relationships

RelationshipDrawn asMeans
AssociationSolid lineThe actor takes part in the use case.
«include»Dashed arrow from the base use case to the included oneThe base always does the included behaviour: placing an order always involves paying.
«extend»Dashed arrow from the extension to the base use caseThe extension sometimes adds to the base: applying a coupon is optional.
GeneralizationHollow triangle at the general actor or use caseA specialized version: a Member is a Customer who can do more.

In UML Wizard: use the Actor, Use Case and System tools. Use cases inside a system boundary move with it.

Common mistakes

Component diagrams

The question it answers: what are the big, replaceable building blocks of the system, and through which interfaces do they depend on each other? Component diagrams show the architecture above the level of classes.

«component» Web Frontend «component» Order Service «component» Payment Service IOrders IPayments uses uses
Simplified from Architecture → Shop Components.

Elements

In UML Wizard: add components and interfaces, then connect a component to the interface it provides with a realization, and the components that need it with a dependency. Label a dependency with how it's used, e.g. HTTPS.

Common mistakes

Deployment diagrams

The question it answers: where does the software run? Deployment diagrams show the machines, runtimes and files, and how the machines are connected.

«device» Customer PC «device» Web Server «executionEnvironment» Kestrel «artifact» shop-web.dll Database Server «executionEnvironment» PostgreSQL HTTPS TCP 5432
Simplified from Architecture → Shop Deployment.

Elements

ElementDrawn asMeans
Node3-D boxA computational resource that software runs on.
Device3-D box with «device»A physical machine: a server, a PC, a phone.
Execution environmentBox with «executionEnvironment», usually inside a nodeSoftware that hosts other software: an operating system, a container runtime, a web server, a database engine.
ArtifactBox with «artifact» and a document iconA concrete file that gets deployed: a program, a library, a script, a database file.
Communication pathSolid line between nodes, labelled with the protocolThe nodes can talk to each other: HTTPS, gRPC, TCP 5432.
«deploy»Dashed arrow from an artifact to a nodeThe artifact is installed on the node. Placing the artifact inside the node says the same thing.
«manifest»Dashed arrow from an artifact to a componentThe file is the physical form of a component: orders.dll manifests Order Service.

In UML Wizard: nodes, devices and execution environments contain whatever you place inside them, and move it along when they move. Connect nodes with Path and label it with the protocol.

Common mistakes

Notes and text boxes

Every diagram type can have notes: UML's comments, drawn as a rectangle with a folded corner and linked to what they describe by a dashed line. Use a note for something the notation can't say, such as “Refunds are issued within 5 working days.” on the Cancelled state.

Cancelled Refunds are issued within 5 working days.

In UML Wizard: add a note with Note and link it with Attach Note. Notes attached to a class become its documentation comment when you generate code. A Text Box is a free label, such as a title or a legend; unlike a note it isn't part of the UML model.

Where to go next

UML Wizard draws a practical subset of UML 2.5.1. Constructs such as packages, combined fragments (alt, loop) in sequence diagrams, composite states and swimlanes aren't available. Help → About UML Wizard shows the supported UML version.