You are on page 1of 37

Activity Diagram

Unified Modeling Language


Introduction
• Activity diagram is basically a flow chart to represent the flow form one activity
to another activity. The activity can be described as an operation of the system

• So the control flow is drawn from one operation to another.


• This flow can be sequential, branched or concurrent.

• Activity diagram is some time considered as the flow chart


Activities
• An activity itself can describe the implementation of a use case.
• An activity is depicted as a rectangle with rounded corners and can, just like an
operation, have parameters.
• you should position input parameters at the left
• and output parameters at the right

• An activity to be read from left to right and/or from


top to bottom

• You can specify pre conditions and post conditions


for an activity.
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
Activity Diagram Notations
1. Initial State – The starting state before an activity takes place is
depicted using the initial state.

2. Action or Activity State – An activity represents execution of an


action on objects or by objects. We represent an activity using a
rectangle with rounded corners. Basically any action or event that takes
place is represented using an activity.
3. Action Flow or Control flows – Action flows or
Control flows are also referred to as paths and edges.
They are used to show the transition from one activity
state to another.
4. Decision node and Branching – When we need to
make a decision before deciding the flow of control, we
use the decision node
3. Action Flow or Control flows – Action flows or
Control flows are also referred to as paths and edges.
They are used to show the transition from one activity
state to another.
4. Decision node and Branching – When we need to
make a decision before deciding the flow of control, we
use the decision node
5. Guards – A Guard refers to a statement written next to a decision node on
an arrow sometimes within square brackets.

6. Fork – Fork nodes are used to support concurrent activities.


7. Join – Join nodes are used to support concurrent activities converging into
one. For join notations we have two or more incoming edges and one
outgoing edge.

8. Merge or Merge Event


.
– Scenarios arise when activities which are not
being executed concurrently have to be merged. We use the merge notation
for such scenarios. We can merge two or more activities into one if the
control proceeds onto the next activity irrespective of the path chosen.
9.Swimlanes We use swimlanes for grouping related activities in one
column. Swimlanes group related activities into one column or one row.
Swimlanes can be vertical and horizontal. Swimlanes are used to add
modularity to the activity diagram. It is not mandatory to use swimlanes.
They usually give more clarity to the activity diagram. It’s similar to creating
a function in a program. It’s not mandatory to do so, but, it is a
recommended practice..

10. Time Event


10. The state which the system reaches when a particular process or activity
ends is known as a Final State or End State. We use a filled circle within a
circle notation to represent the final state in a state machine diagram. A
system or a process can have multiple final states.

.
How to Draw an activity diagram

• Identify the initial state and the final states.


• Identify the intermediate activities needed to reach the final state
from he initial state.
• Identify the conditions or constraints which cause the system to
change control flow.
• Draw the diagram with appropriate notations
Example of an activity
Action and Edges
• The basic elements of activities are actions
• Edges express the order in which the actions are executed and thus define the
execution steps of an activities

1) Event-Based Action
• Event-based actions enable objects and signals to be transmitted
to receiver objects.

2) Call Behavior Action


• Actions can call activities themselves
• Marked with an invert fork
Event-Based Action & Call Behavior Action Example
• Event-Based Action

• Call Behavior Action


Control Flows Initial node indicates where the execution of an activity begins.
• Activities consist of other activities and actions that are connected to one another by edges

If an action
receives a token, The passing of a token can be a weight may be placed on an
the action is prevented by a guard evaluating Weight of edge to allow a certain
active and can be to False number of tokens to be
executed. consumed
Control Flows Contd.
• Multiple initial nodes are also permitted for
each activity

• Branches using
Decision node

• Example of decision behavior


Control Flows Contd.
A parallelization node is depicted Black bar with multiple
as a black bar with one incoming incoming edges but
edge and multiple outgoing edges. only one outgoing edge

• Example of the use of


parallelization and
synchronization nodes

• Example of multiple activity final nodes in


one activity diagram
Activity Diagram - elements
Object Node
Initial Node

Action Node

Fork Join

Activity Final
Decision Node
Guard
Online Shopping Store
• Online customer can browse or search items, view specific item, add it to shopping cart, view and
update shopping cart, checkout. User can view shopping cart at any time. Checkout is assumed to
include user registration and login.
• Shopping cart can be checked out at any time
• User can checkout any time.
• following are actions:
• Search Items, Browse Items, View Items, Add to Shopping Cart, Update Shopping Cart, View Shopping Cart,
Checkout – or more.
Partitions (Swinlane)
• Swim lane visually group the action states

• A partition allows you to group nodes


and edges of an activity based
common properties
Partitions Contd.
• A partition can itself be subdivided into multiple sub partitions
Exception Handling
• As an exception handler is an activity node, it is depicted
as a rectangle with rounded corners. The action safeguarded
by the exception handler points to the exception handler
with a lightning bolt arrow
Exception Handling Contd.
• The interruptible activity region offers a further way to
handle exception.
Issuance of Student ID Card System
Two actors are involved in the process to be modeled: the Student and Employee

To obtain a student ID, the student must request this ID from an employee of
the student office

The employee hands the student the forms that the student has to fill out to
register at the university

Once the student has filled out the forms, the student returns them to the
employee and hands over documents

The employee checks the documents. If the documents are incomplete, the process
is terminated immediately.

If the documents are all in order, the employee checks whether the student has
filled out the student ID correctly

If there are any errors, this ID is destroyed and the student has to fill out another
one

Otherwise the ID is stamped/granted.

However, the student ID is not valid until it bears the semester label sent to the
student by post
Examples
Activity diagram "Passenger Services"
An Activity Diagram: Order Processing System

• Requested order is input parameter of the activity.


• After order is accepted and all required information is filled in, payment is
accepted and order is shipped.
• Note, that this business flow allows order shipment before invoice is sent
or payment is confirmed.
Pizza Ordering System
• Draw an activity diagram
representing each step of the
pizza ordering process, from the
moment you pick up the phone
to the point where you start
eating the pizza.

• Include activities that others need


to perform.
• Use an appropriate partition
mechanism
Ticket Vending Machine
• Activity is started by an user who needs to buy a
ticket. Ticket vending machine will request trip
information from user. This information will
include number and type of tickets, e.g. whether
it is a monthly pass, one way or round ticket,
route number, destination or zone number, etc.
• Based on the provided trip info ticket vending
machine will calculate payment due and request
payment options. Those options include payment
by cash, or by credit or debit card. If payment by
card was selected by user, another actor, Bank
will participate in the activity by authorizing the
payment.
• After payment is complete, ticket is dispensed to
the user. Cash payment might result in some
change due, so the change is dispensed to the
user in this case. Ticket vending machine will
show some "Thank You" screen at the end of the
activity
Solution
Draw an activity diagram showing
the process of reserving a flight.
First, you enter the dates. Once you
submit your desired flight plan, you
can enter your personal information
and at the same time the system
could be searching availability. The
system flow then joins back into
one and you can select the specific
flight on the dates you want to fly.
This activity diagram gives you two
different paths dependent on
whether you are using reward
points. After entering payment
information, the system performs
two processes at the same time
which are seat allocation and
payment process then sends out a
confirmation email

You might also like