UML Activity Diagram Examples

Activity diagrams are a powerful visual tool for modeling workflows, and understanding them can greatly boost your productivity. But what does an UML activity diagram look like in practice? Let's break down some examples to understand the components and their functions.

an activity diagram with instructions to use
an activity diagram with instructions to use

Before diving into examples, let's briefly recap the key elements of an UML activity diagram: activity, action, control flow, object flow. Now, let's explore some practical scenarios.

Client Challenge
Client Challenge

Basic Activity Diagram Example

Let's begin with a simple example: a diagram for ordering a pizza. It should have clear actions and a straightforward flow:

a flow diagram with several different types of items in each area and the following steps
a flow diagram with several different types of items in each area and the following steps

1. Start with the activity 'Order Pizza'. Then, the control flow moves to 'Select Crust'. After deciding the crust, the flow goes to 'Choose Toppings'. Finally, after adding all the toppings, the flow reaches the final action 'Submit Order' and ends.

Control Flow

a flow diagram with several different types of items in each section, including the following steps
a flow diagram with several different types of items in each section, including the following steps

The control flow in this diagram is sequential. It moves from one action to another in a straight line, depicting the natural order of events in an ordering process.

Quiz: What happens if you want to change the crust after selecting the toppings? You'd need a decision point to backtrack, right?

Object Flow

Order System UML Activity Diagram
Order System UML Activity Diagram

Object flow is inactive in this simple diagram. But we can add it to represent the 'Pizza' object, which passes through all actions from 'Select Crust' to 'Submit Order'.

Challenge: Draw the same pizza ordering process again, this time including an object flow for the 'Pizza' object to make it more interactive.

Complex Activity Diagram Example

Activity Diagram for Student Enrollment System  |  UML
Activity Diagram for Student Enrollment System | UML

Now, let's delve into a more intricate scenario: a diagram for processing a loan application. This process often involves multiple branches and swimlanes for different roles.

The control flow begins with 'Receive Application'. It then splits into two branches: 'Verify Income' and 'Check Credit Score'. These action branches merge back together at 'Decision'. If approved, the flow goes to 'Issue Loan'. If rejected, it moves to ' Notify Applicant'.

Login Google Apps UML Activity Diagram
Login Google Apps UML Activity Diagram
UML Activity Diagram Overview
UML Activity Diagram Overview
UML Activity Diagram for Online Shopping
UML Activity Diagram for Online Shopping
Activity Diagram for Course Registration System  |  UML
Activity Diagram for Course Registration System | UML
Free Editable Workflow UML Diagram|EdrawMax
Free Editable Workflow UML Diagram|EdrawMax
an activity diagram for user side
an activity diagram for user side
UML diagrams: all 14 types explained with examples
UML diagrams: all 14 types explained with examples

Decisions and Merge Points

The 'Decision' action is where the control flow branches based on a condition. In this case, it uses the output of the 'Verify Income' and 'Check Credit Score' actions to make a decision.

Tip: When drawing complex diagrams, try to keep the flow linear. Use Events and Actions to start and stop activities, keeping decision points clear and defined.

Swimlanes

Swimlanes can help make complex diagrams more understandable by segmenting them based on roles or systems. In the loan application diagram, you could add swimlanes for 'Applicant', 'Lender', and 'Credit Agency' to clearly depict who performs each action.

Tutorial: Try drawing the loan processing diagram again with swimlanes for a clean and organized look.

With these examples, you should now have a solid understanding of UML activity diagrams. Hopefully, you're inspired to start modeling complex processes and workflows in your own projects. Happy diagramming!