Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 50 Β· Modeling with UML

Use Case Diagrams

Learn to read and draw UML use case diagrams: actors, use cases, the system boundary, and the include and extend relationships, with runnable checkers.

A use case diagram gives a one-page answer to the question "who uses this system, and what do they want to achieve?" It is usually the first UML diagram a team draws, because it works for non-programmers: a customer or manager can read it, point at a missing goal and say "we also need to do that." It sits between requirements gathering and detailed design, and it pairs with the written use case scenarios you saw earlier.

A use case diagram shows goals, not steps. It does not say in what order things happen, or how the system works inside. Those details belong to the written scenario behind each use case and to sequence and activity diagrams. UML is a notation, so the pictures here are read-only; the runnable examples are JavaScript stand-ins that store a use case model as data and check it. They imitate what a modeling tool does; they are not a UML tool.

The building blocks

Four things in every diagram

Actor A role outside the system.
Use case A goal the system helps reach.
System boundary A box around what you build.
Relationships Association, include, extend.

Actors stand outside the box; use cases live inside it.

1 / 2

Actors are roles, not people. "Librarian" is an actor; "Maria" is a person who plays that role. One person can play several roles (a librarian who also borrows books), and one role can be played by many people. An actor can also be another system, such as a payment gateway or a scheduler. Actors are drawn as stick figures, or as boxes labeled with the stereotype name when the actor is a system.

A use case is a goal an actor wants to achieve with the system, named as a short verb phrase: "Borrow book", "Reset password". It should deliver observable value to the actor. "Save record to database" is an implementation step, not a use case.

The system boundary is a rectangle labeled with the system name. Use cases go inside, actors outside. The boundary makes scope visible: anything not inside the box is not part of what you are building.

An association (a plain line) connects an actor to a use case it takes part in. Arrowheads are optional; some teams use them to show who starts the use case (the primary actor) and which actors only respond (secondary actors).

Include and extend

Two relationships connect use cases to each other.

Include says a use case always contains the behavior of another. Both "Borrow book" and "Renew book" might include "Check member account" because every borrowing needs the account checked. Draw it as a dashed arrow from the base use case to the included one, labeled <<include>>. Use it to factor out shared behavior and avoid repeating it.

Extend says a use case may be added to another, under a condition. "Pay late fee" might extend "Return book": it happens only when the book is overdue. The dashed arrow points from the extending use case to the base, labeled <<extend>>. The base use case is complete without the extension.

A memory aid: the arrow for include points to the thing that is always needed; the arrow for extend points to the thing being added to. Many teams use extend rarely, because a note in the written scenario ("if overdue, ...") says the same thing more simply.

There is also generalization between actors or between use cases (a "Premium member" is a kind of "Member"), drawn with a hollow triangle arrowhead.

A complete example

Here is a small library system. UML has no dedicated use case syntax in Mermaid, so this uses a flowchart: rounded shapes for use cases, a subgraph for the boundary, and dashed labeled arrows for include and extend. The notation is only an approximation of real UML.

flowchart LR
    member["Member"]
    librarian["Librarian"]
    subgraph lib["Library System"]
        borrow(["Borrow book"])
        returnBook(["Return book"])
        check(["Check member account"])
        fee(["Pay late fee"])
        addBook(["Add book to catalog"])
    end
    member --- borrow
    member --- returnBook
    librarian --- addBook
    librarian --- returnBook
    borrow -. "Β«includeΒ»" .-> check
    fee -. "Β«extendΒ»" .-> returnBook

Members borrow and return; librarians add books and also handle returns. Checking the account is always part of borrowing; paying a fee only extends a late return.

Reading it: the boundary says that cataloging, borrowing and returning are in scope. Two actors share "Return book", which tells us that both roles need that goal supported. Nothing outside the box (for example, buying new books from a supplier) is covered.

Finding use cases

Use cases come from requirements work. Two practical steps:

  1. List actors first. Ask who uses the system, who maintains it, who gets information from it, and which other systems exchange data with it.
  2. For each actor, ask what they want to achieve. Phrase every answer as a goal from the actor's viewpoint, then check it: does it have a clear start, deliver one complete result, and finish in one sitting? If it is too small ("click the submit button") or too big ("run the library"), resize it.

A diagram with more than about 10 to 15 use cases is hard to read. Split a large system into packages, one diagram each.

A stand-in that lists actors per use case

The model below is plain data: actors with the use cases they take part in, plus the include and extend relations. The function builds a table of who can reach each use case. A use case that is included by another is reached by every actor of the base use case, because the base always runs it. It is a small model of what a tool computes from a diagram.

JS Actors per use case

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The output lists "Check member account" under Member even though no line connects them directly, which is exactly what include means. "Pay late fee" is reachable by both actors, but only as an optional extension of returning. If you add a new actor with "Borrow book" in the model, the table updates by itself. Real tools do this kind of derivation so you do not have to track it by hand.

A stand-in that checks the model

Good models can be checked mechanically for simple problems. This second stand-in finds use cases with no actor at all (nobody wants them, so why build them?) and actors with no goals. A use case that appears only as the target of an include counts as reached.

JS Find orphans in a use case model

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Two use cases, "Print shipping label" and "Export reports", have nobody who wants them. Either an actor is missing (a warehouse worker, a manager) or the use cases are not real requirements. The "Payment gateway" actor has no goals yet, a prompt to ask what it does in the system. Finding such gaps while the model is still small is the whole value of the exercise.

Strengths and limits

Use case diagrams are good at showing scope and the actors involved. They are weak at everything else: they hide order, data and conditions, and two teams can draw very different diagrams for the same system. Treat the diagram as an index into the written use cases, not as the specification itself.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. What is an actor in a use case diagram?

    Actors are roles (people or other systems) outside the system boundary. One person can play several roles.
  2. 2. Which relationship fits 'checking the account is always part of borrowing a book'?

    Include means the base use case always contains the other behavior. Extend is for optional behavior added under a condition.
  3. 3. Which is the best use case name?

    A use case is a goal that delivers value to an actor, phrased as a verb phrase. The first two are implementation steps and the last is not a goal.
  4. 4. Where do use cases go relative to the system boundary?

    The boundary marks what you are building. Use cases are inside; actors stay outside.

Summary

  • A use case diagram shows actors, the goals they pursue, and the scope of the system, in a form non-programmers can read.
  • Actors are roles outside the boundary; use cases are verb-phrase goals inside it.
  • Include means always, extend means sometimes under a condition; generalization expresses a "kind of" link.
  • Derive use cases by listing actors, then asking what each one wants; keep one diagram to roughly 15 use cases or fewer.
  • The diagram indexes the written scenarios; it does not replace them.

Next: Class Diagrams.