Activity Diagram in UML

Introduction

In every software application, there's a story playing out — a flow of actions, decisions, and sometimes parallel tasks. UML Activity Diagrams are designed to tell that story visually. They're perfect for modeling business workflows, logic flows, and use case processes in a way that's easy to understand, even without reading the code.

In this tutorial, you’ll learn how to use activity diagrams to represent the dynamic flow of control in a system. We’ll explore notation, real-world Java examples, and walk through detailed cases based on a familiar theme — a school management system.

What is an Activity Diagram?

An Activity Diagram is a behavioral UML diagram that represents the flow of control or object flow. It’s similar to a flowchart but more expressive — able to show concurrency, decisions, loops, and object states.

Basic activity diagram flow with start, actions, decision, and end nodes

Why Use Activity Diagrams?

  • Model workflows: Ideal for describing how a task is accomplished from start to finish
  • Capture use case behavior: Complements use case diagrams by showing internal steps
  • Define logic clearly: Useful for developers, analysts, and testers
  • Bridge design and code: Helps you map flow to Java methods and logic

Key Elements of an Activity Diagram

1. Initial Node

The starting point of the activity. Shown as a filled black circle.

2. Activity (Action) Nodes

Tasks or steps to perform. Shown as rectangles with rounded corners.

3. Decision Node

A branching point. Shown as a diamond shape with outgoing arrows labeled with conditions.

4. Merge Node

Combines multiple alternative flows. Also a diamond, but with multiple incoming flows.

5. Fork & Join Nodes

Fork splits flow into parallel paths. Join synchronizes them. Represented as thick horizontal or vertical bars.

6. Final Node

Marks the end of the activity. Shown as a bullseye (black circle within a white circle).

7. Control Flows

Arrows showing the order of actions.

UML activity diagram symbols for action, decision, fork, join, final

Example Scenario: Exam Registration Process

Step-by-Step Activities

  • Student logs in
  • System checks eligibility
  • If eligible, student selects subjects
  • Submits registration
  • If not eligible, system displays message

Activity Diagram for This Flow

Activity diagram for exam registration process in a school system

Java Analogy

public void registerForExam(Student student) {
  if (!student.isEligible()) {
    showMessage("You are not eligible");
    return;
  }

  List<Subject> subjects = selectSubjects(student);
  submitRegistration(student, subjects);
}

This method corresponds directly with the flow shown in the activity diagram — each line of logic maps to an action or decision node.

How to Create an Activity Diagram: Step-by-Step

Step 1: Define the Process

Identify what task or workflow you’re modeling — e.g., “View Marks,” “Submit Attendance,” etc.

Step 2: List Activities

Break the process into small steps or decisions — login, check eligibility, confirm registration, etc.

Step 3: Start with the Initial Node

Place the black circle to denote the start of the flow.

Step 4: Add Actions and Decisions

Use rectangles for tasks and diamonds for decisions. Label the flows for clarity.

Step 5: End with the Final Node

Place the bullseye to indicate the end of the activity.

Step 6: Add Parallelism (Optional)

If tasks can run concurrently (e.g., notify admin and send confirmation), use a fork/join structure.

More Example: Viewing Student Report

Process Flow

  • Login
  • Check role (student)
  • Fetch report
  • Display report
Activity diagram for student report viewing process

Use Cases for Activity Diagrams

  • Business Process Modeling: Approval processes, workflows, onboarding steps
  • Use Case Detailing: Drill-down into what happens inside a use case
  • Algorithm Visualization: Understand flow before implementing in code
  • Testing: Helps QA teams understand flow for writing test cases

Best Practices

  • Use simple and clear action names: “Check Eligibility” is better than “VerifyProcessStep1”
  • Label decision branches clearly: Use guard conditions like [eligible], [not eligible]
  • Minimize crossing arrows: Keep flow clean and left-to-right or top-to-bottom
  • Group related actions: Use swimlanes or notes to clarify roles if needed

Tools to Draw Activity Diagrams

  • StarUML: Easy-to-use drag and drop editor with UML 2.x support
  • Lucidchart: Great for collaborative flow visualization
  • PlantUML: Text-based diagram generator, perfect for version control
  • draw.io: Free and intuitive tool for quick flow modeling

PlantUML Example

@startuml
start
:Login;
if (Is Eligible?) then (yes)
  :Select Subjects;
  :Submit Registration;
else (no)
  :Show Not Eligible Message;
endif
stop
@enduml
PlantUML activity diagram output for exam registration

Conclusion

Activity Diagrams are an excellent way to visualize the internal flow of a system. They complement use case diagrams by offering depth — showing what actually happens during each process. Whether you're designing a student registration workflow or planning logic for a grading system, activity diagrams help everyone — from developers to testers to stakeholders — see the big picture in motion.

Up next, we’ll take a look at Sequence Diagrams, which focus not on what happens but on who interacts with whom and when — bringing timelines into the picture.

QUIZ

Question 1:What does an Activity Diagram primarily represent in UML?

Question 2:Activity Diagrams can represent both sequential and parallel behavior.

Question 3:Which of the following elements are typically found in Activity Diagrams?

Question 4:Consider a school exam process: 'Distribute papers → Collect responses → Evaluate answers'. What UML tool best models this?

Question 5:In an Activity Diagram, a Fork Node indicates the end of a parallel flow.

Question 6:In which scenarios are Activity Diagrams especially useful?

Question 7:What does a filled circle followed by an arrow typically indicate in an Activity Diagram?

Question 8:Actions and activities can be used interchangeably in UML Activity Diagrams.

Question 9:What are the characteristics of a Decision Node in an Activity Diagram?

Question 10:Given this scenario:
// Student completes homework
// Teacher reviews it and gives feedback
// Feedback may lead to rework or approval
Which element would best represent 'rework or approval' flow in an Activity Diagram?