LLDUML & System ModellingActivity Diagram

Activity Diagram

UML & System Modelling

Sequence diagrams are great for showing interactions between specific objects, but what if you need to model a complex workflow or business process? For example, how would you diagram the entire process of fulfilling an online order, from receiving the order to shipping the package? This involves multiple steps, conditions, and potentially parallel activities.

Activity Diagrams are UML's version of a flowchart. They are used to model the dynamic aspects of a system, describing the flow of control from one activity to another. They are excellent for modeling business processes, workflows, and complex algorithms.

Core Components of an Activity Diagram

  1. Action/Activity: A step in the workflow. Represented by a round-cornered rectangle.
  2. Start Node: The beginning of the workflow. Represented by a small, filled circle.
  3. End Node: The end of the workflow. Represented by a filled circle inside another circle.
  4. Decision Node: A point where the path diverges based on a condition (an if/else). Represented by a diamond shape with one incoming path and multiple outgoing paths, each with a "guard" condition (e.g., [approved], [rejected]).
  5. Merge Node: A point where multiple alternative paths converge back into one. Also represented by a diamond, but with multiple incoming paths and one outgoing path.
  6. Fork Node: A point where the flow splits into multiple concurrent (parallel) activities. Represented by a thick black bar with one incoming path and multiple outgoing paths.
  7. Join Node: A point where multiple concurrent activities synchronize and merge back into a single flow. Represented by a thick black bar with multiple incoming paths and one outgoing path. The flow cannot proceed past the join until all incoming flows have arrived.
Start NodeActionActivityDecisionMergeForkJoinEnd Node

Example: Order Fulfillment Workflow

Let's model the process for fulfilling an order in an e-commerce system.

Workflow:

  1. The process starts when an Order is Received.
  2. A decision is made: Is the payment [approved] or [rejected]?
  3. If rejected, the process ends.
  4. If approved, two things happen in parallel:
    • The Warehouse staff Picks & Packs Items.
    • The Billing department Sends Invoice.
  5. Once both of those activities are complete, the Shipping department Ships Package.
  6. After the package is shipped, the process ends.
Order is Received[rejected][approved]Pick & Pack ItemsSend InvoiceShip Package

Activity vs. Sequence Diagrams

Here are a few points worth noting when comparing Activity Diagrams to Sequence Diagrams:

FeatureActivity DiagramSequence Diagram
PurposeTo model a workflow or process (the "how").To model interactions between objects (the "who" and "when").
FocusFlow of control from activity to activity.Flow of messages between object lifelines.
Key ElementsActions, Decisions, Forks, Joins.Lifelines, Messages, Activation Bars.
Best ForBusiness process modeling, complex algorithms.Detailing a single use case, API interactions.

Activity diagram is a good tool for understanding and communicating complex workflows. They bridge the gap between high-level use cases and low-level class interactions, making them a valuable part of the design process.