Use Case Diagram
The UML picture of who uses a system and what they use it for. It is the fastest way to agree on scope before you draw a single class.
Overview
A use case diagram answers two questions: who interacts with the system, and what do they get from it? The people and outside systems are actors. The things they can do are use cases. A rectangle around the use cases marks the boundary of the system you are designing; everything outside it is someone else's problem.
The notation is defined in clause 18 of UML 2.5.1. An actor is a stick figure with its name nearby. A use case is an ellipse with a verb-noun name such as 'Withdraw cash'. A solid line joins an actor to each use case it takes part in. Two dashed arrows, labeled «include» and «extend», relate use cases to each other.
In an interview, this diagram is a scoping tool. When the prompt is 'design an ATM', listing the actors and use cases first shows the interviewer that you find out what the system must do before you decide how it is built. It also gives you a checklist: every use case should later have a flow (a sequence or activity diagram) and the classes that carry it out.
The parts
The diagram has six elements, and each comes with one drawing rule.
- Actor: a stick figure with its name above or below. It sits outside the boundary, and it is a role, not a person.
- Use case: an ellipse with a verb-noun name. It is a complete goal for an actor, not a step.
- Subject (system boundary): a rectangle with the system's name at the top. Use cases go inside it, and actors stay outside.
- Association: a solid line from an actor to a use case. It means the actor takes part in that use case.
- Include: a dashed arrow with an open head, from the base to the included use case, labeled «include». The base always runs the included behavior.
- Extend: a dashed arrow with an open head, from the extension to the extended use case, labeled «extend». The extension runs only under a condition, at an extension point.
Interview questions
- What is the difference between include and extend, and which way do the arrows point?
- How do you identify the actors of a system?
- How detailed should the diagram be?
- How does a use case diagram turn into the rest of the design?
- When would you use a use case diagram instead of user stories?
Sign up free to read the full topic
More Low-Level Design topics
Start free on Cariara · Coding problems · System design studio