Anda di halaman 1dari 42

Activity Diagrams

Introduction(I)
Activity diagrams describe procedural
logic, business process, and workflow.

Activity diagrams focus on the action


sequence of execution and the conditions
that trigger or guard those actions.

Activity diagrams focus on the activitys


internal actions, not on the external
interfaces
Introduction(II)
Activity diagrams have similarities to
flowcharts
But flowcharts notation does not support parallel
behavior.
Business managers may prefer activity diagrams
over flowcharts, because they are more
understandable for non-technical people.

An activity diagram is a special case of state


chart diagram in which states are actions.
Introduction(III)
An activity diagram shows flow control
within a system.

Handle Document Archive


Incident Incident Incident
Activity Diagram Elements
Initial node
Activity final node
Action
Flow/edge
Fork
Join
Decision
Merge
Synch
Activity Diagram Syntax
Action or Activity
Represents action or set of actions
Control Flow
Shows sequence of execution
Initial Node
The beginning of a set of actions
Final Node
Stops all flows in an activity
Decision Node
Represents a test condition
Activity Diagram Syntax
Model conditional behavior using Branch
and Merge

Model parallel behavior using a fork and a


join
Sample Activity Diagram
Guidelines for Activity Diagrams
1. Set the scope of the activity being
modeled
2. Identify the activities, control flows, and
object flows that occur between the
activities
3. Identify any decisions that are part of the
process being modeled
4. Identify potential parallelism in the
process
5. Draw the activity diagram
Basic ElementsAction(I)

Action in Activity Diagram Elements


official UML name is action state.

Distinction between action and activity


Action state refers to it as action
Use term activity only refer to the whole
task being modeled by the activity diagram
Basic ElementsAction(II)
The rounded rectangle represents an
action that occurs.

E.g., Customer calls ticket office :

Customer Calls Ticket Office

A sample action that is part of an activity diagram


Basic Elements--Initial state
The filled circle is the staring point of the
diagrams.
An initial node isnt required.

First Action To DO

The initial state shows the starting point for the action sequence
within an activity diagram.
Basic Elements--Initial state(II)
Initial state can indicate only ONE action.

Action 1

Action 2

Incorrect rendering of an initial state within an


activity diagram. The initial state can indicate only
ONE action
Basic ElementsFlow/edge
The arrow on the diagram. There is a
subtle difference between flows and edges.
Basic ElementsFinal node
The filled circle with a border is the
ending point.
An activity diagram can have zero or more
activity final nodes

First Action To DO
Decision
A diamond with one flow entering and
several leaving.
[Drink contains
alcohol]
Make Sure Customer Is At
least 21 Years Old

Customer
Orders Drink

Get Drink For


[else]
Customer
Merge
A diamond with several flows entering and
one leaving. Tell Customer To
Order A Non
Alcoholic Drink

Make Sure
Customer Is At
least 21 Years Old [customers age < 21]
[Drink contains
Customer alcohol]
Orders Drink [customers age >= 21]

[else]

Get Drink For


Customer
Synch
A thick, solid line, allowing two or more
action sequences to proceed in parallel

Action 1
Fork
Synch with one flow going into it and several
leaving it.
Denotes the beginning of parallel actions.
Verify Order
Products Are In
Stock

Receive Order

Verify Customer
Has Available
Credit
Join
Synch with several flows entering and one
leaving.
All incoming flows must reach it before
processing may continue. This denotes the end
Verify Order
of Products
parallel processing.
Are In
Stock

Accept Order

Verify Customer
Has Available
Credit
Signals
An Activity diagram can have a clearly
defined start point, which corresponds to an
invocation of a program or routine.
Activity diagram can also show response to
signals.
A time signal occurs because of the passage
of time (for example, each month end might
trigger a signal.)
A real time signal indicates that the activity
receives an event from an outside process.
The activity listens for those signals, and the
diagram defines how the activity reacts.
Signals
Activity diagrams can show signals sent or
received
For example, we can send a message and then
wait for a reply before we can continue.
Basically, the signals are flow triggers.

Send signal Time signal Accept signal


Flow
Connection between 2 actions
Simple flow
- arrow
- from a node to another

Flow with Exception


Flows (cont.)
Flow with objects

Flow with pins


- similar to flows with objects
- data needed and data produced
Flows (cont.)
Decision flows
-labeled

Connectors
- does the same job as a simple
arrow
Tokens
Tokens flow through the diagrams:

The initial node creates a token, executes, passes


the token to the next
Fork produces a token on each of its outward
flows.
On a join, as each inbound token arrives, nothing
happens until all the tokens appear at the join; then
a token is produced on the outward flow.
Join Specification
Boolean expression using the names of the incoming edges
to specify the conditions under which the join will emit a token.
Evaluated whenever a new token is offered on any incoming
edge.
Default - "and
Expansion Region
Structured activity region that
executes multiple times
corresponding to elements of an
input collection.

Example:
The hotels may be booked
independently and concurrently
with each other and with
booking the flight.
Advanced Notation
Conditional threads

Nested activity diagrams

Partitions
Conditional threads
One of a set of
concurrent threads is
conditional.

Example:
Frequent-flyer
member?
Award the passenger
frequent flyer miles.
Nested Activity Diagram
diagram refers to an
external one that uses
more abstraction
Partitions
The contents of an activity
diagram may be organized
into partitions

Does not have a formal


semantic interpretation

May represent
organizational unit
Dimensional Partition

Dimensional Partition
Dimensional Partition

Multidimensional Hierarchical Diagram


Activity vs. Sequence Diagrams

Activity diagrams give focus to the workflow


Sequence diagrams give focus to the handling of
business entities.

Activity diagram with partitions focuses on how


you divide responsibilities onto classes
The sequence diagram helps you understand how
objects interact and in what sequence.
When to Use Activity Diagrams
Describe a behavior which contains
parallel activities

Or

Show how behaviors in several use-cases


interact.
Specification standards

No need for documenting the Activity


diagrams
beyond diagram itself.

However, most UML tools provide in-built


documentation capturing and printing
capabilities for the Activity diagram and its
elements.
UML Activity diagram editor
Questions on Activity Diagrams
Books:
References
Freeman, Freeman, Sierra, and Bates, Head First Design Patterns,OReilly 2004, p. 73
Gamma, Helm, Johnson, and Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley 1995.

Websites:
Activity Diagrams:
http://www.agilemodeling.com/artifacts/activityDiagram.htm
http://computersciencesource.wordpress.com/2010/03/15/software-engineering-activity-diagrams/
http://www.cse.unt.edu/~rgoodrum/Teaching/2009/fall/4910/website%20files/handouts/umlbasicsp2_actdg.pdf
http://www.devx.com/ibm/Article/21615
http://edutechwiki.unige.ch/en/UML_activity_diagram
http://www.sa-depot.com/?p=158
http://sourcemaking.com/uml/modeling-business-systems/external-view/activity-diagrams
http://www.uml-diagrams.org/activity-diagrams.html

Observer:
http://www.blackwasp.co.uk/Observer.aspx
http://www.cs.clemson.edu/~malloy/courses/patterns/observer.html
http://www.codeproject.com/KB/architecture/Observer_Design_Pattern.aspx
http://java.dzone.com/articles/observer-pattern?utm_source=am6_feedtweet&utm_medium=twitter&utm_campaign=toya256ForRSS
http://www.patterndepot.com/put/8/observer.pdf
http://sourcemaking.com/design_patterns/observer
http://userpages.umbc.edu/~tarr/dp/lectures/Observer.pdf