Activity Diagram
Activity Diagram
Activity Diagrams describe how activities are coordinated to provide a service which can be
at different levels of abstraction. Typically, an event needs to be achieved by some
operations, particularly where the operation is intended to achieve a number of different
things that require coordination, or how the events in a single use case relate to one
another, in particular, use cases where activities may overlap and require coordination. It is
also suitable for modeling how a collection of use cases coordinate to represent business
workflows
1. Identify candidate use cases, through the examination of business workflows
2. Identify pre- and post-conditions (the context) for use cases
3. Model workflows between/within use cases
4. Model complex workflows in operations on objects
5. Model in detail complex activities in a high level activity Diagram
Activity Diagram - Learn by Examples
The activity diagram example below visualize the flow in graphical form.
A swimlane is a way to group activities performed by the same actor on an activity diagram
or activity diagram or to group activities in a single thread. Here is an example of a swinlane
activity diagram for modeling Staff Expenses Submission:
Activity
Is used to represent a set of actions
Action
A task to be performed
Control Flow
Shows the sequence of execution
Object Flow
Show the flow of an object from one activity (or
action) to another activity (or action).
Initial Node
Portrays the beginning of a set of actions or activities
Object Node
Represent an object that is connected to a set of
Object Flows
Decision Node
Represent a test condition to ensure that the control
flow or object flow only goes down one path
Merge Node
Bring back together different decision paths that
were created using a decision-node.
Fork Node
Split behavior into a set of parallel or concurrent
flows of activities (or actions)
Join Node
Bring back together a set of parallel or concurrent
flows of activities (or actions).
Swimlane and Partition
A way to group activities performed by the same
actor on an activity diagram or to group activities in a
single thread
Flowcharts were typically invented earlier than activity diagrams. Non programmers
use Flow charts to model workflows. For example: A manufacturer uses a flow chart
to explain and illustrate how a particular product is manufactured. We can call a
flowchart a primitive version of an activity diagram. Business processes where
decision making is involved is expressed using a flow chart.
So, programmers use activity diagrams (advanced version of a flowchart) to depict
workflows. An activity diagram is used by developers to understand the flow of
programs on a high level. It also enables them to figure out constraints and
conditions that cause particular events. A flow chart converges into being an activity
diagram if complex decisions are being made.
Brevity is the soul of wit. We need to convey a lot of information with clarity and
make sure it is short. So an activity diagram helps people on both sides i.e.
Businessmen and Developers to interact and understand systems.
A question arises:
Do we need to use both the diagram and the textual documentation?
Different individuals have different preferences in which they understand something.
For example: To understand a concept, some people might prefer a written tutorial
with images while others would prefer a video lecture.
So we generally use both the diagram and the textual documentation to make our
system description as clear as possible. We also need to be sensitive to the needs of
the audience that we are catering to at times.
Difference between a Use case diagram and an Activity diagram
An activity diagram is used to model the workflow depicting conditions, constraints,
sequential and concurrent activities. On the other hand, the purpose of a Use Case
is to just depict the functionality i.e. what the system does and not how it is done. So
in simple terms, an activity diagram shows ‘How’ while a Use case shows ‘What’ for
a particular system.
The levels of abstraction also vary for both of them. An activity diagram can be used
to illustrate a business process (high level implementation) to a stand alone
algorithm (ground level implementation). However, Use cases have a low level of
abstraction. They are used to show a high level of implementation only.
Figure – an activity diagram for an emotion based music player
The above figure depicts an activity diagram for an emotion based music player
which can also be used to change the wallpaper.
The various components used in the diagram and the standard notations are
explained below.
1. Initial State – The starting state before an activity takes place is depicted using
the initial state.