What is an Activity Diagram?
An Activity Diagram is a UML diagram that models the flow of control or data from one activity to another. It's essentially a sophisticated flowchart that can show concurrency, decision making, and parallel processing. Activity diagrams are great for modeling business processes, workflows, and algorithms.
Unlike sequence diagrams (which focus on object interactions), activity diagrams focus on the activities or actions that happen β who or what performs them is less important than what happens and in what order.
Activity Diagram Notation
Basic Elements:
1. Initial Node (solid circle)
β
2. Activity Final Node (solid circle with ring)
β
3. Action (rounded rectangle)
ββββββββββββββββββββββ
β Action Name β
ββββββββββββββββββββββ
4. Decision Node (diamond with incoming/outgoing arrows)
β
β outgoing edges have [guard conditions]
5. Merge Node (diamond with multiple incoming, one outgoing)
β
6. Fork Node (horizontal bar β splits flow into parallel)
βββββββ
7. Join Node (horizontal bar β merges parallel flows)
βββββββ
8. Swimlanes (vertical/horizontal partitions)
ββββββββββ¬βββββββββ¬βββββββββ
β Actor1 β Actor2 β Actor3 β
β β β β
Example: Order Processing Workflow
Order Processing Activity Diagram:
β
β
βΌ
ββββββββββββββββββββ
β Receive Order β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Validate Items β
ββββββββββ¬ββββββββββ
β
βΌ
β
β± β²
β± β²
[valid] [invalid]
β± β²
βΌ βΌ
ββββββββββββ ββββββββββββββββ
β Process β β Notify β
β Payment β β Customer β
ββββββ¬ββββββ ββββββββ¬ββββββββ
β β
βΌ β
β β
β± β² β
β± β² β
[paid] [failed] β
β± β² β
βΌ βΌ β
βββββββββ ββββββββ β
β Ship β βRefundβ β
β Order β β β β
βββββ¬ββββ ββββ¬ββββ β
β β β
βΌ βΌ β
ββββββββββββββββββββ β
β Send Receipt β β
ββββββββββ¬ββββββββββ β
β β
βΌ β
β β
β² β
β²βββββββββββ
Swimlanes (Partitions)
Swimlanes divide activities by who or what performs them. They add accountability and clarity to complex workflows:
ββββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ
β Customer β System β Payment β Warehouseβ
β β β Gateway β β
ββββββββββββΌβββββββββββΌβββββββββββΌβββββββββββ€
β β β β β
β Browse β β β β
β items β β β β
β β β β β β
β βΌ β β β β
β Add to β β β β
β cart β β β β
β β β β β β
β βΌ β β β β
β Checkout β β β β
β β β β β β
β βΌ β β β β
β β Validate β β β
β β order β β β
β β β β β β
β β βΌ β β β
β ββββββββββββΆ β β
β β β Process β β
β β β payment β β
β β β β β β
β βββββββββββββ β β β
β β β β β
β βββββββββββββββββββββββΆ β
β β β β Pick & β
β β β β pack β
β β β β items β
β β β β β β
β ββββββββββββββββββββββββ β β
β β β β β
β Receive β β β β
β package β β β β
β β β β β
Fork and Join β Parallel Activities
Fork nodes split a single flow into multiple parallel flows. Join nodes wait for all parallel flows to complete before continuing:
Fork and Join Example:
βββββββ β Fork (split into 3 parallel flows)
β± β β²
βΌ βΌ βΌ
ββββββββββ ββββββββββ ββββββββββ
β Send β β Update β β Notify β
β Email β β Stock β β Admin β
βββββ¬βββββ βββββ¬βββββ βββββ¬βββββ
β β β
βββββββ β Join (wait for all 3 to complete)
β
βΌ
ββββββββββββββββ
β Order Completeβ
ββββββββββββββββ
All three actions happen in parallel.
The flow continues only after ALL three complete.
Activity Diagram vs Flowchart
βββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β Feature β Activity Diagram β
βββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ€
β Notation β UML standard β
β Swimlanes β Built-in support β
β Parallel processing β Fork/Join nodes β
β Object flow β Can show data passing β
β Exceptions β Exception handlers supported β
β Partitioning β By actor/system/responsibility β
βββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ
When to use:
β’ Modeling business processes β Activity Diagram
β’ Simple algorithm logic β Flowchart is fine
β’ Complex workflows with parallel steps β Activity Diagram
β’ Quick sketch for communication β Flowchart is fine