Use Case Diagram in UML

Introduction

Before a single line of Java code is written, there's one essential question every developer must answer: What should the system do? That’s where Use Case Diagrams come in.

In UML, a Use Case Diagram is a visual tool that describes the functional requirements of a system — what the system should do from the perspective of an end user or external system. It’s simple, clear, and incredibly useful, especially at the early stages of software development.

What is a Use Case Diagram?

A Use Case Diagram shows the interactions between actors (users or external systems) and use cases (specific functionalities or goals). It defines the who and the what of a system, not the how.

It’s a bird’s-eye view of the system's functionality — one that helps both technical and non-technical stakeholders stay aligned.

Basic use case diagram showing actors and use cases

Why Use a Use Case Diagram?

  • Gather requirements: Captures user needs clearly
  • Align stakeholders: Bridges business and development teams
  • Scope planning: Defines the system’s boundaries
  • Test case foundation: Serves as a basis for designing test scenarios

Key Elements of Use Case Diagrams

1. Actor

Anything that interacts with the system from the outside — a user, another system, or a device. Represented as a stick figure.

Actor: Student, Teacher, Admin

2. Use Case

An action or goal the actor wants to achieve. Represented as an oval.

Use Cases: Register, Upload Marks, View Report

3. System Boundary

A rectangle that defines the scope of the system. Use cases go inside; actors stay outside.

4. Relationships

  • Association: Solid line connecting actor to use case
  • Include (<>): Common functionality used by multiple use cases
  • Extend (<>): Optional or conditional behavior
  • Generalization: Inheritance between actors or use cases
Use case diagram with include and extend relationships

Real-World Example: School Management System

Actors

  • Student: Wants to view marks, register for exams
  • Teacher: Uploads marks, views schedule
  • Admin: Adds subjects, assigns teachers

Use Cases

  • Login
  • View Marks
  • Register for Exam
  • Upload Marks
  • Manage Schedule
  • Assign Subjects

Use Case Diagram

This diagram illustrates how actors interact with the system’s key functionalities:

Use case diagram for school management system with 3 actors and multiple use cases

Java Analogy

// Actor interaction mapped to controller method
@GetMapping("/view-marks")
public String viewMarks(@RequestParam int studentId) {
  return markService.getMarks(studentId);
}

Here, viewMarks is a use case in the diagram and implemented as a Java method in the backend.

Step-by-Step: How to Draw a Use Case Diagram

Step 1: Identify Actors

Ask: Who will use or interact with the system? Don’t forget external systems or devices.

Step 2: List Use Cases

What do these actors want to accomplish? Focus on goals, not implementation.

Step 3: Draw the System Boundary

Create a rectangle and name it after the system, like School System.

Step 4: Place Actors Outside, Use Cases Inside

Draw stick figures for actors, and connect them to use cases with solid lines.

Step 5: Add Relationships

Use <<include>> for shared logic and <<extend>> for optional steps.

Use Case Relationship Examples

Include

Login is included in most flows:

Student --> (Register for Exam)
(Register for Exam) --> (Login) <<include>>

Extend

Viewing detailed feedback may extend the basic view marks feature:

(View Marks) --> (View Feedback) <<extend>>
Use case diagram showing include and extend relationships in school system

Common Mistakes to Avoid

  • Focusing on UI instead of behavior
  • Modeling implementation details instead of goals
  • Forgetting external actors like payment gateways or reporting services
  • Overcomplicating with too many details

Best Practices

  • Use clear actor names: Avoid generic labels like "User"
  • Stick to user goals: Use cases should express what the user wants
  • Group related use cases: Helps simplify large diagrams
  • Complement with narratives: Add textual descriptions for each use case

Tools for Creating Use Case Diagrams

  • StarUML: Drag-and-drop actors and use cases
  • Lucidchart: Collaborative and easy to share with stakeholders
  • PlantUML: Perfect for text-based diagram generation
  • draw.io: Free and intuitive for quick modeling

PlantUML Example

@startuml
actor Student
actor Teacher
actor Admin

rectangle "School System" {
  (Login)
  (View Marks)
  (Register for Exam)
  (Upload Marks)
  (Assign Subjects)

  Student --> (Login)
  Student --> (View Marks)
  Student --> (Register for Exam)
  Teacher --> (Login)
  Teacher --> (Upload Marks)
  Admin --> (Assign Subjects)
}
@enduml
PlantUML use case diagram for a school system example

Conclusion

Use Case Diagrams are one of the easiest ways to start modeling a system. They strip away technical complexity and focus on what really matters — what the system does for its users. Whether you’re gathering requirements, presenting to stakeholders, or preparing to implement in Java, use case diagrams help you stay aligned and focused on delivering value.

In the next lesson, we’ll zoom into the interactions themselves — using Sequence Diagrams to model message flows over time.

QUIZ

Question 1:What is the primary goal of a Use Case Diagram in UML?

Question 2:An actor in a Use Case Diagram must always represent a human user.

Question 3:Which of the following are valid elements of a Use Case Diagram?

Question 4:In the context of a school management system, which of the following is MOST likely a use case?

Question 5:An 'include' relationship in a Use Case Diagram means that one use case always requires another to complete its behavior.

Question 6:Which of the following scenarios best represent an 'extend' relationship?

Question 7:How is a use case typically represented in UML diagrams?

Question 8:Generalization relationships between actors allow one actor to inherit interactions from another.

Question 9:In a library system, which of these could be valid actors?

Question 10:Consider this real-world situation:
// A teacher can either grade or review assignments
// Grading optionally includes feedback
Which Use Case Diagram relationship does 'includes feedback' represent?