Home
6UML Use Case Diagrams
6

Topic 6 of 9 · Lab VII

UML Use Case Diagrams

Actors, use cases and system boundaries; association, include, extend and generalization; use case descriptions with main and alternative scenarios, using the ATM system.

← → move between slides · F full screen · M slide list

Before we start

Why this matters

A bank manager does not care about classes or tables. She wants to know: what can a customer do at this machine?

A use case diagram answers that on one page. It turns the SRS into goals that users recognise and fixes the scope: what is inside the system and who is outside.

It is also the bridge to the next diagrams: every use case becomes one or more sequence diagrams.

Outline · Lab VII

Topics in this chapter

Select a topic to jump to the slide that explains it.

  1. Use cases
  2. Notation
  3. Relationships
  4. The ATM example
  5. Building your diagram
  6. Common mistakes

Concept 1 of 12

What a use case diagram shows

A use case is a goal a user achieves with the system, together with the scenarios (success and failure) that happen along the way. A use case diagram is a UML behaviour diagram that shows the actors, their use cases and the relationships between them.

  • It captures the user’s view: what the system offers, not how it works inside.
  • It organises the functional requirements of the SRS.
  • It fixes the system’s scope: what is inside the boundary and who is outside.
  • Each use case is later described in text and detailed in sequence diagrams (topic 7).
Problem statement (from the manual): in the old banking system customers depended on bank employees for every transaction. With an ATM the customer does the transaction in person — withdrawing money, checking the balance, getting a mini statement and transferring money after validating the PIN — which is faster and more private.

Concept 2 of 12

The notation

Actor, use case, system boundary and the four kinds of link.

Concept 2 of 12

The notation (cont.)

ElementMeaning
Actor (stick figure)a role outside the system that interacts with it: a person, organisation or another system
Use case (ellipse)a goal, named verb + object: “Withdraw cash”
System boundary (box)what is inside the system; actors stay outside
Association (solid line)this actor takes part in this use case
Generalization (hollow triangle)a specialised actor or use case inherits from a general one
«include»the base use case always uses the included one
«extend»the extension adds optional behaviour to the base
Package (folder)groups related use cases in big diagrams

Notation

Actors: roles, not people

  • An actor is a role. One person can play several roles (a librarian who also borrows books is both Librarian and Member).
  • Primary actors start a use case to reach their goal (Customer). They are usually drawn on the left.
  • Secondary (supporting) actors help the system do its work (Bank server, SMS gateway, payment gateway). Usually on the right.
  • Time can be an actor for scheduled jobs (“Send due-date reminder” started by a Clock).
  • The system itself, its database and its screens are never actors.
Is it an actor?Answer
Customer✓ primary
Bank central computer✓ secondary (external system)
ATM database✗ part of the system
Card reader✗ usually part of the ATM system
Mr. Karim✗ a person; use his role

Concept 4 of 12

Include, extend and generalization

The arrows of «include» and «extend» point in opposite directions.

Concept 4 of 12

Include, extend and generalization (cont.)

«include»«extend»
Meaningthe base always performs the included behaviourthe extension sometimes adds behaviour to the base
Arrowfrom base → includedfrom extension → base
The base without itis incompleteis complete
Typical useshared steps (authenticate, validate card)optional or exceptional steps (print receipt, pay fine)
Condition / extension pointnonenamed in the base use case

Interactive

Include or extend?

Concept 6 of 12

The ATM use case diagram

Four customer goals share Authenticate; handling an excess amount extends Withdraw cash.

Concept 6 of 12

The ATM use case diagram (cont.)

  • Customer (primary) starts all four transactions.
  • Bank server (secondary) is involved in each, because the ATM must ask the bank for account data.
  • Every transaction «include»s Authenticate: it always happens first.
  • Handle excess amount «extend»s Withdraw cash at the extension point “excess amount” — only when the amount is too large.

Redrawn from the manual’s Figure VII.14 (Request Cash, Request Balance, Request Statement, Request Balance Transfer, User Identify, Process Excess Amount).

The ATM example

Describing a use case in text

The diagram is only an index. Each use case also needs a use case description (specification):

FieldWithdraw cash (UC-02)
ActorsCustomer (primary), Bank server (secondary)
PreconditionThe ATM is in service and has cash
TriggerThe customer inserts a card
Main success scenario1 Insert card · 2 system reads the card · 3 system asks the bank for account details · 4 system asks for the PIN · 5 customer enters PIN · 6 PIN authenticated · 7 customer enters amount · 8 system checks the balance with the bank · 9 cash dispensed, account debited · 10 card returned, receipt printed
Alternative flows2a card unreadable → return card, end · 3a bank unreachable → return card, end · 6a wrong PIN → two more tries; third failure keeps the card · 8a insufficient funds → enter a smaller amount or cancel
PostconditionAccount debited by exactly the cash dispensed; transaction recorded

Interactive

Walk through the scenarios

Concept 9 of 12

Finding actors and use cases

Ask these questions of the SRS and the users:

  1. Who uses the system to get their work done? (primary actors)
  2. Who installs, maintains or administers it?
  3. Which other systems does it talk to? (secondary actors)
  4. For each actor: what goals do they have? Each goal that gives them a result of value is a use case.
  5. What must happen at a certain time? (time as an actor)
The “coffee-break” test: a use case is a goal after which the user could happily take a break. “Withdraw cash” passes; “Enter PIN” does not — it is a step inside a use case.

Building your diagram

Drawing it step by step

  1. Draw the system boundary and name it.
  2. Place primary actors on the left, secondary actors on the right.
  3. Add use cases inside the box, named verb + object, in a sensible order.
  4. Connect each actor to its use cases with associations.
  5. Look for steps shared by several use cases → «include».
  6. Look for optional or exceptional behaviour → «extend» (name the extension point).
  7. Use generalization only for true “is a kind of” relations.
  8. Give use cases IDs (UC-01…) and write a description for each.

In Visual Paradigm: Diagram Navigator → Use Case Diagram → New; pick System, Actor and Use Case from the toolbar; drag from a shape’s resource icon to create connected use cases, «include» and «extend»; use Package to group use cases; set ID formats under Tools → Options → Diagramming.

Building your diagram

Drawing it step by step (cont.)

PlantUML source
@startuml
left to right direction
actor Customer
actor "Bank server" as Bank
rectangle "ATM system" {
  usecase "Withdraw cash" as W
  usecase "Authenticate" as A
  usecase "Print receipt" as P
}
Customer -- W
W -- Bank
W ..> A : <<include>>
P ..> W : <<extend>>
@enduml
Output · the diagram PlantUML draws
Use case diagram drawn by PlantUML: Customer and Bank server linked to Withdraw cash inside the ATM system, which includes Authenticate and is extended by Print receipt

The same idea written in PlantUML, a text-to-diagram tool: you type the text on top and it draws the diagram below.

Concept 11 of 12

Common mistakes

MistakeWhy it is wrongFix
Steps as use cases (“Enter PIN”, “Click OK”)too small; no goalmerge into the goal (“Withdraw cash”)
Arrows between use cases showing orderuse case diagrams do not show sequenceuse a sequence or activity diagram
«include» arrow drawn towards the basedirection reversedbase → included
Database or UI drawn as an actorthey are inside the systemremove them
Actors inside the boundaryactors are outside by definitionmove them out
Dozens of includesfunctional decomposition, not goalskeep includes for genuinely shared behaviour
No descriptionsthe diagram alone is ambiguouswrite a description per use case

Your turn

Your turn: the Library Management System

Before drawing, list from the scenario:

QuestionYour list
Who are the actors?(roles in the scenario: which are primary, which secondary?)
What goals does each actor have?(register, request, reserve, renew, return, pay fine, give feedback, maintain records…?)
What is shared by several goals?→ candidate «include»
What happens only sometimes?→ candidate «extend» (hint: fines)
  • Is “Issue library card” a goal of the user or of the librarian?
  • Are “Add record”, “Delete record” and “Update record” three use cases or one (“Maintain records”)? Justify it.
  • Does a student and a staff member do different things? If so, consider actor generalization.
Submit your own diagram and descriptions; these prompts are only a starting point.

Worked example 1 of 3

Worked example 1

An online shop: a customer can browse products, place an order and track it. Placing an order always requires logging in. The customer may apply a coupon while placing an order. A payment gateway processes payments. Identify actors and relationships.
Show the solution
  • Actors: Customer (primary), Payment gateway (secondary).
  • Use cases: Browse products, Place order, Track order, Log in, Apply coupon.
  • Place order «include» Log in (always).
  • Apply coupon «extend» Place order (optional; extension point “coupon entered”).
  • Payment gateway is associated with Place order.

Worked example 2 of 3

Worked example 2

Which of these are good use cases for an ATM? (a) Press Enter (b) Withdraw cash (c) Read magnetic strip (d) Change PIN (e) Connect to database
Show the solution
(b) and (d) are goals with value to the customer. (a) is a UI step, (c) is an internal step, (e) is an implementation detail.

Worked example 3 of 3

Worked example 3

Draw the arrow for: “Borrowing a book always checks the member’s card.” and “Returning a book late triggers a fine.”
Show the solution
Borrow book ⇢ Check card, labelled «include» (arrow from Borrow book). Pay fine ⇢ Return book, labelled «extend» (arrow from Pay fine to Return book, with the extension point “book is overdue”).

Practice

Practice (1 of 2)

Try each one on paper first, then check your answer.

1. What is the difference between a primary and a secondary actor?
Show the answer
A primary actor starts the use case to achieve its own goal; a secondary actor supports the system during the use case (e.g. a bank server or payment gateway).
2. In which direction does the «include» arrow point?
Show the answer
From the base use case to the included use case.
3. Give one example of actor generalization in a university system.
Show the answer
Student and Teacher both generalise to Member (or User): each inherits Member’s associations, such as Log in and Search catalogue.

Practice

Practice (2 of 2)

Try each one on paper first, then check your answer.

4. Lab task hint: which scenario sentence suggests an «extend» relationship in the Library Management System?
Show the answer
Paying a fine happens only if a book is returned late or not renewed — optional, conditional behaviour on Return book.
5. Why is “Database” not an actor?
Show the answer
It is part of the system being modelled; actors are always outside the system boundary.
6. List the fields of a use case description.
Show the answer
Name/ID, actors, preconditions, trigger, main success scenario, alternative flows (and exceptions), postconditions (optionally priority and frequency).

Check yourself

Quiz

Resources

Further learning (cont.)

ToolVisual Paradigm Online ↗Free online UML editor (the manual’s recommended tool).ToolStarUML ↗Desktop UML modeller (the manual calls it “StartUML”).StandardOMG Unified Modeling Language specification ↗The official UML standard (current version 2.5.1).
BookWriting Effective Use Cases — Alistair CockburnAddison-Wesley, 2000. The classic on use case descriptions, goals and scenarios.
BookUML Distilled, 3rd ed. — Martin FowlerAddison-Wesley, 2003. A short, practical guide to all the UML diagrams in this course.

Summary

Summary

  • A use case is a user goal plus its scenarios; the diagram shows actors, use cases and the system boundary.
  • Actors are roles outside the system: primary actors start use cases, secondary actors support them.
  • «include»: always, base → included. «extend»: optional, extension → base.
  • Generalization means “is a kind of” for actors or use cases.
  • Every use case needs a description with main and alternative flows.
  • Avoid steps as use cases, order arrows, and internal parts drawn as actors.