You are on page 1of 18

Activity diagrams

Activity Diagrams
• Activity diagrams are particularly useful in connection with
workflow and in describing behavior that has a lot of parallel
processing.

• It describes the sequencing of activities, with support for both


conditional and parallel behavior.

• It is a variant of state diagram in which most, if not all, the states


are activity states.

• It shows the flow from activity to activity.

• An activity is an ongoing non atomic execution within a state


machine.
Activity Diagrams
• The core symbol is the activity state or activity. It is
a state of doing something: execution of a software
routine.

• Conditional behavior is defined by branches and


merges.
Activity Diagram
Activity Diagram

• A branch has a single incoming transition and


several guarded outgoing transitions.

• The guard condition should be mutually exclusive.

• A merge has multiple input transitions and a single


output.

• It marks the end of conditional behavior started by


a branch.
Activity Diagram

• Parallel behavior is indicated by forks and joins.

• A “fork” has one incoming transition and several


outgoing transitions.

• When the incoming transition is triggered, all of the


outgoing transitions are taken in parallel.

• It means the sequence between them is irrelevant.


Activity Diagram

Key difference between flowchart and activity


diagram:

• Flowcharts are normally limited to sequential


processes, whereas activity diagrams can handle
parallel processes/concurrent programs.
Activity Diagram

• Every “fork” must have a “join” that joins together


the threads started by that “fork.”

• With a “join”, the outgoing transition is taken only


when all states on the incoming transitions have
completed their activities.
Activity Diagram

•A condition can be added to a thread that is coming out


of a “fork”.

•The result is a conditional thread.

•During execution if the condition on a conditional


thread is false, that thread is considered to be complete as
the “join” is concerned.
Activity Diagram

Decomposing an activity
• An activity can be broken down into sub activities.
• It is similar to super state and sub states on a state
diagram.
• The parent diagram can be decoupled from the
contents of the subsidiary diagram.
Using a composite activity for delivery
Dynamic Concurrency
•It helps to show iterations without having to construct a
loop.
•The activity fill line item is executed once for each line item
on the order.
•The multiplicity marker * indicates that the activity is
executed many times.
•The transition to deliver order is triggered only when all the
line items have been filled.
Swimlanes

• Activity diagrams tells what happens, but they do not tell


who does what.

• The diagram does not convey which people or departments


are responsible for each activity.

• Swimlanes are a way around this.


Swimlanes

• To use swimlanes, the activity diagram is arranged into


vertical zones separated by lines.

• Each zone represents the responsibilities of a particular


class.

• They combine activity diagram’s depiction of logic with the


interaction diagram’s depiction of responsibility.
When to use activity diagrams

Strength

• It support and encourage parallel behavior.

• Tool for workflow modeling and multithreaded


programming.

Disadvantage
• Do not make the links among actions and objects very clear.
When to use activity diagrams
• Analyzing a Use Case

• Understanding workflow

• Describing a complicated sequential algorithm

• Dealing with multithreaded applications.


When not to use activity diagrams

• Trying to see how objects collaborate

• Trying to see how an object behaves over lifetime

• Representing complex conditional logic

You might also like