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.
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.
| Sentence | Adds |
|---|---|
| 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).
| «include» | «extend» | |
|---|---|---|
| Arrow goes | from base to included | from extension to base |
| Runs | always | only if its condition holds |
| Base without it | is not complete | is complete |
| Typical use | a step shared by several use cases | an 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.
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.