Anda di halaman 1dari 36

Activity diagrams

Introduction
Activity diagrams are a behavioural model that
represent the dynamics of the system.
An activity diagram is essentially a fancy flowchart.
they show the flow of control from activity to activity
in the system,
What activities can be done in parallel and
any alternate paths in the flow.
Activity diagrams can be used to show the flow across
use cases or they may be used to represent the flow
within a particular use case
Introduction
Activity diagrams and state chart diagrams are
related.
Activity diagrams are a special type of state.
because activities are the state of doing something.
While a state chart diagram focuses attention on an
object undergoing a process (or on a process as an
object),
an activity diagram focuses on the flow of activities
involved in a single process.
Activity diagram shows the how those activities
depend on one another..
The diagrams describe the state of activities by
showing the sequence of activities performed.
Contents of an activity diagram

Activities represented as rectangles with rounded


edges.
Transitions between the activities, drawn as
directed arrows,
Decision points shown as diamonds, and
Synchronisation bars represented with thick or
vertical bars.
Activity

An activity represents the perfomance of some


behavior in the workflow

Create curriculum
Select course to teach

Create catalogue
Flow Transitions
Transitions are used to show the passing of the
control from one activity to another.
Shows how the action states are related to another.
They are triggered by the completion of the
behavior in the originating activity.

Create curriculum

Select course to teach

Create catalogue
Types of transitions

There are two kinds


Control flow
Object flow
Control flow
Indicates the order of action states
That is, once a source action state completes its processing, a target
action state starts its processing.
For example, the project management system may have the
following order of action states for the task of generating a report:
1. The Project Manager Enters Report Criteria action state occurs
first, because the project manager must enter the report criteria
before the system can generate a report.
2. The Project Management System Generates Report action state
occurs next, because the project management system must generate
the report before the printer can print the report.
3. The Printer Prints Report action state occurs last, once the report
has been generated by the project management system.
Control flow

Control-flow transitions are also known as default transitions or automatic


transitions,
because they are unlabeled and are immediately triggered after the source
action state completes processing.
Object flow
An object-flow transition indicates that an action state
inputs or outputs an object.
For example, the action states shown in the Figure (next
slide) may have inputs and outputs as follows:
Project Manager Enters Report Criteria
Outputs a Report Criteria object and may be renamed as the Project
Manager
Enters Data action state
Project Management System Generates Report
Inputs the Report Criteria object and outputs a Report object and may be
renamed as the Project Management System Generates Information
action state
Printer Prints Report
Inputs the Report object and may be renamed as the Printer Prints
Information action state
Object flows
The advantage of using object flows is that action
state names can now focus purely on the actions,
while the object-flow transitions indicate clearly
the inputs and outputs to and from the actions.
Transition flows
A control-flow transition may be omitted when an
object-flow transition indicates the ordering of action
states; that is,
when an action state produces an output that is input to a
subsequent action state, the object-flow transition implies a
control-flow transition and an explicit control-flow
transition is not necessary.
Decision points

When modelling the workflow of a system it is


often necessary to show where the flow of control
branches based on decision points.
The transitions from a decision point contain a
guard condition, which is used to determine which
path from the decision point is taken.
Decisions along with their guard conditions allow
you to show alternate paths through a workflow.
Decision points

Create curriculum

Select course to teach

Assign professor to course

Are all professors


Assigned?
A transition with a guard

Create curriculum

Select course to teach

Assign professor to course

No
Are all professors
Assigned?
Decisions

Notice that because the diamond shape is in the project


managers swimlane, the project manager is responsible
for making the decision.
Concurrency
In a workflow some activities may be perfomed at the
same time.
A syncronisation bar allows you to specify which
activities may be performed concurrently.
In the UML, concurrency is shown using a short heavy bar.
If a bar has one incoming transition and two or more
outgoing transitions, it indicates that all outgoing transitions
occur once the incoming transition occurs. This is called
splitting of control.
If a bar has two or more incoming transitions and one
outgoing transition, it indicates that all incoming transitions
must occur before the outgoing transition occurs. This is
called synchronization of control.
Syncronisation Bars

Create curriculum

Select course to teach

Assign professor to course

No
Are all professors
Assigned?

Yes
Yes

Create catalogue

Place catalogue in book Mail catalogue


store To students

Open registration
Concurrency
Swimlanes
Swimlanes may be used to partition an activity diagram.
This is mainly done to show what person or organisation
is repsonsible for the activities contained in the
swimlane
For example, the project management system may have
the following swimlanes, which are illustrated in Figure
below:
Project Manager
Shows the action states that are the responsibility of a project
manager. The swimlane makes it obvious that the project
manager is responsible for entering data, thus the rather
cumbersome action state name of Project Manager Enters
Data may be shortened to Enter Data.
Swimlanes
Project Management System
Shows the action states that are the responsibility of the
project management system. Again, because the swimlane
makes it obvious who (or what, in this case) is generating
information, the rather cumbersome action state name of
Project Management System Generates Information may be
shortened to Generate Information.
Printer
Shows the action states that are the responsibility of a printer.
Because of this swimlane, the rather cumbersome action state
name of Printer Prints
Information may be shortened to Print Information.
Swimlanes
Registra Professor
Create curriculum

Select course to teach

Assign professor to course

No
Are all professors
Assigned?

Yes
Yes

Create catalogue

Place catalogue in book Mail catalogue


store To students

Open registration
Swimlanes example
Initial and final activities

There are special symbols that are used to show


the starting and final activities in a work flow
The starting activity is shown using a solid filled
circle and the final activities are shown using a
bulls eye.
Typically theres one starting activity for the work
flow and there may be more than one ending
activity (One for each alternate flow in the
workflow).
Initial and final activities

Create curriculum

Select course to teach

Assign professor to course

No
Are all professors
Assigned?

Yes
Yes

Create catalogue

Place catalogue in book Mail catalogue


store To students

Open registration
Diagrams used
Initial node. The filled in circle is the starting point of the
diagram. An initial node isnt required although it does make it
significantly easier to read the diagram.
Activity final node. A filled circle (Bull eye) with a border is
the ending point. An activity diagram can have zero or more
activity final nodes.
Activity. The rounded rectangles represent activities that
occur. An activity may be physical, such as Inspect Forms, or
electronic, such as Display Create Student Screen.
Flow/edge. The arrows on the diagram.
Diagrams used
Fork. A black bar with one flow going into it and several
leaving it. This denotes the beginning of parallel activity.
Join. A black bar with several flows entering it and one
leaving it. This denotes the end of parallel processing.
Condition. Text such as [No] on a flow, defining a guard
which must evaluate to true in order to traverse the node.
Decision. A diamond with one flow entering and several
leaving. The flows leaving include conditions although
some modelers will not indicate the conditions if it is
obvious.
Diagrams used
Merge. A diamond with several flows entering and one
leaving. The implication is that all incoming flows must
reach this point until processing continues, unless otherwise.
Partition. Also called swimlanes, indicates who/what is
performing the activities.
Sub-activity indicator. The rake in the bottom corner of an
activity, indicates that the activity is described by a more
finely detailed activity diagram.
Flow final. The circle with the X through it. This indicates
that the process stops at this point.
Signal: When an activity sends or receives a message,
that activity is called a signal.
Signals are of two types: Input signal (Message receiving activity)
shown by a concave polygon and Output signal (Message sending
activity) shown by a convex polygon.
How to Draw: Activity Diagrams
Activity diagrams show the flow of activities through the
system.
Diagrams are read from top to bottom and have branches
and forks to describe conditions and parallel activities.
A fork is used when multiple activities are occurring at the same time.
The diagram below shows a fork after activity1.
This indicates that both activity2 and activity3 are occurring at the same
time.
After activity2 there is a branch.
The branch describes what activities will take place based on a set of
conditions.
All branches at some point are followed by a merge to indicate the end of
the conditional behavior started by that branch.
After the merge all of the parallel activities must be combined by a join
before transitioning into the final activity state.
Example
Below is a possible activity diagram for processing an
order.
The diagram shows the flow of actions in the system's
workflow.
Once the order is received the activities split into two
parallel sets of activities.
One side fills and sends the order while the other handles
the billing.
On the Fill Order side, the method of delivery is decided
conditionally.
Depending on the condition either the Overnight Delivery
activity or the Regular Delivery activity is performed.
Finally the parallel activities combine to close the order.
When to Use: Activity Diagrams
Activity diagrams should be used in conjunction with
other modeling techniques such as interaction diagrams
and state diagrams.
The main reason to use activity diagrams is to model the
workflow behind the system being designed.
Activity Diagrams are also useful for:
analyzing a use case by describing what actions need to take
place and when they should occur;
describing a complicated sequential algorithm;
and modeling applications with parallel processes.
However, activity diagrams should not take the place
of interaction diagrams and state diagrams.
Activity diagrams do not give detail about how objects behave
or how objects collaborate.

Anda mungkin juga menyukai