The idea: goals, seen from outside

Before anyone designs classes, a team has to agree on what the system is for. A use case diagram answers that in one picture. It shows who uses the system and which goals they reach with it. It does not show how the system works inside. Each person or outside system is an actor, a stick figure. Each goal is a use case, an oval. The ovals sit inside a rectangle, the system boundary (UML calls it the subject), and the actors stand outside it.

A small use case diagram with its parts named. A rectangle labelled Bookshop is the system boundary. Outside it on the left, the stick figure Customer, and below it Member, joined to Customer by a line with a hollow triangle at Customer: generalization. Inside, the ovals Place Order, Log In and Apply Coupon. A solid line from Customer to Place Order is an association. A dashed arrow labelled include goes from Place Order to Log In. A dashed arrow labelled extend goes from Apply Coupon to Place Order, whose oval lists the extension point payment.
The parts: actors outside the boundary, use cases inside it, and four kinds of line between them.

The canvas starts from nine short requirement sentences for an online bookshop. Press Next Sentence to read them one at a time. The words that matter fly from the sentence into the diagram, and the number after each sentence says how many elements it added. After all nine the diagram has 4 actors, 7 use cases, 6 associations, 3 «include», 1 «extend» and 1 generalization: 22 elements.

Finding actors and use cases in text

Read each sentence and ask two questions. Who acts? A role that uses the system, such as "customer" or "staff", is an actor. What does that role want? A phrase like "can place an order" is a goal, and a goal is a use case. Name it with a verb and a noun: Place Order, not Order or Order Form.

An actor is a role, not a person. One person can be a customer in the morning and staff in the afternoon. A role that comes up again is not drawn again: R2 names the customer a second time and adds no actor. An actor can also be another system. The payment service in R7 is outside the bookshop, so it is an actor too. It is a supporting actor: the bookshop calls it. The customer is a primary actor: it starts the use case to reach its own goal.

SentenceAdds
R1 A customer can browse the catalog.actor Customer, use case Browse Catalog, association (+3)
R2 A customer can place an order.use case Place Order, association (+2)
R3 To place an order, the customer must log in.use case Log In, Place Order «include» Log In (+2)
R5 Staff log in to manage the catalog.actor Staff, use case Manage Catalog, association, «include» (+4)
R6 When paying, a customer may enter a coupon.extension point payment, use case Apply Coupon, «extend» (+2)
R9 Every page loads in under 2 seconds.nothing (+0)

R9 names no role and no goal. It is about speed, a non-functional requirement. Such requirements are real, but they go in a separate list (often called the supplementary specification), not on the diagram. Demo 4: generalization, and no use case (R7 to R9).

Association and the boundary

An association is a plain solid line between an actor and a use case. It says the actor takes part in that use case. It has no arrowhead on this page, and it does not mean data flows one way. Draw an association only from an actor to a use case. Two actors are never joined by an association, and two use cases are joined only by «include» or «extend». Demo 1: actors and use cases from R1, R2.

«include» and «extend»

Placing an order, tracking an order and managing the catalog all need the user to log in. Writing the login steps three times would be wasteful. So Log In becomes a use case of its own, and each of the three includes it. An «include» is a dashed arrow from the base use case to the included one. The included steps always run, at a fixed place in the base. On the canvas, Log In gets three «include» arrows and no association: nobody logs in just for fun. Demo 2: include, a shared step (R3 to R5).

A coupon is different. Placing an order works without it. «extend» adds optional behaviour to a base use case. The arrow goes the other way: from the extension, Apply Coupon, to the base, Place Order. The base names the place where the extra steps may run, an extension point, in its oval under a line: here payment. A condition says when the extension runs, here "a coupon was entered". Demo 3: extend at an extension point (R6).

Two panels side by side. Left, include: an arrow from Place Order to Log In, and below it the steps of Place Order with step 2 Log In always running. Right, extend: an arrow from Apply Coupon to Place Order, and below it the steps of Place Order with the extension point payment at step 4, where Apply Coupon runs only if a coupon was entered.
«include» points at the shared part, which always runs; «extend» points at the base, and the extra part runs only at its extension point when the condition holds.
«include»«extend»
Arrow goesfrom base to includedfrom extension to base
Runsalwaysonly if its condition holds
Base without itis not completeis complete
Typical usea step shared by several use casesan option or a special case

Actor generalization

"A member is a customer who can also write reviews." That sentence makes Member a kind of Customer. Generalization is a solid line with a hollow triangle at the parent. The child actor takes part in all the parent's use cases, so a Member can browse, place orders and track orders without three more lines. Member also has an association of its own, to Write Review, which a plain Customer does not have. Use cases can be generalized the same way, but that is rarer.

From use case to flows

The oval is only the name of a goal. The detail is written as text, a use case specification. It has the actors, a main flow (the usual path, as numbered steps that go back and forth between actor and system) and alternative flows. An alternative flow is numbered after the step where it branches off: 5a branches off at step 5 of Place Order when the card is declined. It says what happens instead, and whether the use case goes back to a step or ends.

An «include» shows up in the text as a step ("include Log In"). An extension point is marked at its step ("step 4, extension point payment").

One flow as a system sequence diagram

One run of one flow can be drawn as a system sequence diagram. It has one lifeline per actor and one for the whole system, drawn as a black box (:Bookshop). Each step where something crosses the system boundary becomes a message. A request is a solid arrow with a filled head, a reply is a dashed arrow back. Steps inside the system, such as "System checks them", draw nothing. An included use case becomes a ref frame that points to its own diagram.

Left, the main flow of Place Order as seven numbered steps. Right, the system sequence diagram with lifelines Customer, :Bookshop and Payment Service. Lines link each step to its message: step 1 to placeOrder(), step 2 to a ref frame Log In, step 3 to the reply cart: 3 items, 55, step 4 to confirm(), step 5 to charge(55), step 6 to the reply approved and step 7 to the reply order 1042.
Each step that crosses the boundary becomes one message, in the same order; the include becomes a ref frame.

The counts on the canvas follow from this. Place Order's main flow has 7 steps: 3 calls, 3 replies and 1 ref frame. Its alternative flow 5a also has 3 calls and 3 replies, but they end with "declined" and "payment declined". Log In's alternative flow runs 6 steps for 4 messages: steps 2 and 2 again stay inside the system. Demo 5, Demo 6 and Demo 7. The next level of detail, the objects inside :Bookshop calling each other, is the subject of UML Sequence Diagram: Drawn One Message at a Time. The cart there is the same: pen 5, book 20, lamp 30.

Common mistakes

  • Functions instead of goals. "Validate Card", "Save Order" and "Send Email" are steps inside Place Order, not goals of an actor. A diagram with dozens of small ovals is a function list.
  • Arrows for order or data. A use case diagram has no time order. It does not say that Browse Catalog comes before Place Order. Order belongs in the flows, or in an activity diagram.
  • An association to an included use case. A line from Customer to Log In would say that logging in is a goal on its own.
  • The «extend» arrow the wrong way. It points at the base, which does not know about the extension.

See also UML Class Diagram: Every Line Next to Its Java (the nouns in the same text often become classes), Scrum Sprint (user stories, the lighter cousin of use cases) and Boundary Value Testing (each flow of a use case is a test case to write).

See also A CI/CD Pipeline from Push to Production for how the built system is tested and delivered once the use cases are coded.

What the page leaves out

The page draws the extension condition only in words; UML puts it in a note attached to the «extend» arrow, and an extend can have several extension points. It leaves out use case generalization, multiplicities on associations, actors drawn as boxes with «actor», and packages that group use cases. The flow texts are short; a full specification also lists preconditions, postconditions, triggers and special requirements. The system sequence diagram shows only calls and replies, without loops or alternatives in one diagram.

On the mind map

Open the Software Design mind mapSoftware DesignPrinciples: keep each change localPrinciplesDesign patterns: named fixes for common designsDesign patternsArchitecture: the shape of a whole appArchitectureEnterprise app patterns: logic, SQL, locks, money (PoEAA)Enterprise app patternsGit storage: content named by its hashGit storageGit branches & merging: pointers to commits, then mergeGit branches & mergingTesting: check code in isolationTestingHexagonal architectureHexagonal architecturedomain in the middle, adapters at portsLayered vs Pipes vs EventsLayered vs Pipes vs EventsClosed layers add hops; queues absorb faultsMicrokernel plug-insMicrokernel plug-insSmall core; rules plug in via a contractUML Sequence DiagramUML Sequence DiagramTime runs down; one arrow per callUML class diagramUML class diagramA field is a line; diamond = whole and partsUse Case Diagraminclude always runs, extend is optionalState and activity diagramsState and activity diagramsExits inside out, entries outside inVirtual DOM diffingVirtual DOM diffingdiff new tree vs old, patch only changesMVC vs MVVMMVC vs MVVMController routes input; view-model bindsOpen the Software Design mind mapSoftware Designthe shape of a whole appArchitectureHexagonal architectureHexagonal architecturedomain in the middle, adapters at portsLayered vs Pipes vs EventsLayered vs Pipes vs EventsClosed layers add hops; queues absorb faultsMicrokernel plug-insMicrokernel plug-insSmall core; rules plug in via a contractUML Sequence DiagramUML Sequence DiagramTime runs down; one arrow per callUML class diagramUML class diagramA field is a line; diamond = whole and partsUse Case Diagraminclude always runs, extend is optionalState and activity diagramsState and activity diagramsExits inside out, entries outside inVirtual DOM diffingVirtual DOM diffingdiff new tree vs old, patch only changesMVC vs MVVMMVC vs MVVMController routes input; view-model binds
This page on the Software Design mind map · 41 pages in 7 branches · open it to see the whole map and test yourself in recall mode.