Skip to main content

Use Case Diagram

Editorial

Purpose of the Use Case Diagram

The use case diagram answers a fundamental question: who interacts with the Elevator System, and what can they do?

Before we dive into classes and code, we need a clear picture of the system boundary — what's inside our design and what's outside. The use case diagram defines:

  • Actors — the external entities that interact with the system (people, other systems)
  • Use Cases — the specific goals each actor can accomplish
  • System Boundary — what our Elevator System is responsible for
  • Relationships — how use cases relate to each other (include, extend)

This diagram connects directly to our requirements: each functional requirement from R2 to R10 maps to one or more use cases (R1, the building's floors and elevators, is structure, which the class diagram covers).

Identifying Actors

From our requirements, we can identify three actors:

1. Passenger (Primary Actor)
The person who uses the elevator. A passenger performs two distinct interactions:

  • Makes a hall call from a floor (presses UP or DOWN button) — from R2
  • Makes a cabin call inside the elevator (presses a destination floor) — from R3

Note: We model the passenger as a single actor even though their interaction happens in two phases (outside, then inside the elevator). Some designs split this into "Waiting Passenger" and "Riding Passenger" — but since it's the same person in sequence, a single actor is cleaner.

2. Elevator System / Dispatcher (System Actor)
The internal controller that receives requests and coordinates elevators. While this is technically part of our system, it acts as an actor when interacting with individual elevators. The dispatcher:

  • Assigns hall calls to the optimal elevator — from R4
  • Manages scheduling algorithm execution — from R7

3. Maintenance Technician (Secondary Actor)
In a complete system, a technician can take an elevator out of service, run diagnostics, or reset the system. While this is out of our core scope, including it in the use case diagram shows awareness of real-world actors. We'll mark these use cases as out of scope.

Identifying Use Cases

Each use case is a complete goal an actor can achieve:

Passenger Use Cases:

  • UC1: Make Hall Call — Passenger presses UP or DOWN button on their floor. The system registers the request and assigns it to an elevator. This includes UC4.
  • UC2: Make Cabin Call — Passenger inside an elevator presses a destination floor button. The elevator adds this floor to its stop queue.
  • UC3: View Floor Display — Passenger views the display on their floor showing elevator positions and directions.

Dispatcher Use Cases:

  • UC4: Dispatch Elevator — When a hall call arrives, the dispatcher selects the best elevator based on the scheduling algorithm. This includes UC5.
  • UC5: Execute Scheduling Algorithm — The dispatcher runs FCFS, SCAN, or LOOK to determine which elevator should handle a request. This is an included use case — it's always part of dispatching.

Elevator Use Cases (internal):

  • UC6: Update Floor Displays — After an elevator moves, it notifies all floor displays to update — they observe the elevator.
  • UC7: Move to Floor — The elevator moves one floor in its current direction, checking for stops. This includes UC6.
  • UC8: Open/Close Doors — The elevator opens doors at a stop, waits, then closes them. This extends UC7: it runs only when the elevator stops at a requested floor.

Maintenance Technician Use Cases (out of scope):

  • UC9: Take Elevator Out of Service — Mark an elevator as unavailable.
  • UC10: Run Diagnostics — Trigger a self-test cycle.

Relationships between use cases:

  • UC1 (Make Hall Call) includes UC4 (Dispatch Elevator) — every hall call the system registers is dispatched to an elevator
  • UC4 (Dispatch Elevator) includes UC5 (Execute Scheduling Algorithm) — dispatching always requires running the algorithm
  • UC7 (Move to Floor) includes UC6 (Update Floor Displays) — every floor the elevator moves to is reported to the floor displays that observe it
  • UC8 (Open/Close Doors) extends UC7 (Move to Floor) — the doors open and close only where the elevator stops for a request; passing a floor runs no door cycle

An «include» always runs as part of its base use case; an «extend» runs only when its condition holds — which is why opening the doors extends moving: the elevator passes most floors with its doors shut.

Run the Use Case Diagram

The system boundary rectangle encloses all use cases that are part of our Elevator System. Actors sit outside the boundary, connected to the use cases they interact with — the Dispatcher too, as a system actor. The diagram below runs on the Code Implementation's ElevatorSystem, in the usage example's building: 10 floors, two elevators, LOOK scheduling. Press ▲ or ▼ on a floor to make a hall call — it includes Dispatch Elevator, which includes the scheduling algorithm — and see which elevator scores best. Click an elevator and press a floor inside it for a cabin call. Then step the clock: every floor an elevator moves to updates the floor displays, and the doors open only where it stops for a request. Click a floor's display to read it.

Interactive: the Elevator System use case diagram runs live on the lesson's code, beside the usage example's building — 10 floors and two elevators with LOOK scheduling. Make Hall Call (press ▲ or ▼ on a floor) includes Dispatch Elevator, which includes Execute Scheduling Algorithm: the status line gives each elevator's LOOK score and pending requests, and a tie goes to the elevator with fewer pending requests. A lit button refuses a second press until an elevator stops for the call (R10). Make Cabin Call — click an elevator, then press a floor inside it — goes straight into that elevator's queue, without the Dispatcher. Step or Run the clock: Move to Floor includes Update Floor Displays on every floor an elevator moves to; Open / Close Doors extends Move to Floor and runs only where the elevator stops for a request, while a floor it passes is checked and skipped. View Floor Display shows where each elevator last reported. The Dispatcher stands outside the boundary as a system actor; the Maintenance Technician's two use cases are out of scope. Undo and Reset; eight missions; a quick check answered on the diagram.

Complete Use Case Diagram

UML use case diagram of the Elevator System. Outside the system boundary: the Passenger (primary actor) on the left, the Dispatcher («system» actor) on the right, and the greyed-out Maintenance Technician at the far right. Inside, three groups: the Passenger's Make Hall Call, Make Cabin Call and View Floor Display; the Dispatcher's Dispatch Elevator (associated with the Dispatcher) and Execute Scheduling Algorithm; and the elevator's internal Open / Close Doors, Move to Floor and Update Floor Displays. Make Hall Call «include» Dispatch Elevator, Dispatch Elevator «include» Execute Scheduling Algorithm, Move to Floor «include» Update Floor Displays, and Open / Close Doors «extend» Move to Floor, with a note giving its condition: the elevator stops at a requested floor. A dashed Out of scope box holds the technician's Take Elevator Out of Service and Run Diagnostics.

Key Design Decisions

1. Why is the Dispatcher a system actor, not just a use case?

The Dispatcher is an autonomous controller within our system — it makes decisions (which elevator to send) without direct human input. Modeling it as a system actor highlights that it has agency: it doesn't just respond to requests, it decides how to handle them. In the class diagram, the Dispatcher will be a full class with strategy and state.

2. Why separate Hall Call and Cabin Call as distinct use cases?

They have different actors (outside vs. inside the elevator), different data (hall call has floor + direction; cabin call has floor only), and different handling (hall call goes through the dispatcher; cabin call goes directly to the elevator's queue). Merging them would obscure these fundamental differences.

3. Why is "Execute Scheduling Algorithm" included rather than standalone?

A scheduling algorithm never runs in isolation — it only runs as part of dispatching a request. The «include» relationship makes this dependency explicit: every dispatch operation executes the algorithm.

4. Why show out-of-scope use cases?

In an interview, showing awareness of real-world features — even if you explicitly de-scope them — demonstrates domain understanding. Saying "I'm aware of maintenance mode but I'll focus on core dispatch" is better than not mentioning it at all.