Chapter 11

advertisement
Chapter 11
Activity Diagrams
Introduction
• “Activity diagrams are a technique to describe
procedural logic, business processes, and work
flows” - M. Fowler
• An activity diagram...
– models the dynamic aspects of a system.
– serves the same function as a flowchart.
– Is composed of a sequence of actions, possibly
concurrent
2
Terms and Concepts
• An activity diagram…
– is commonly used to show the actions/steps involved in
carrying out a particular use-case.
– Shows the flow from action to action.
– Commonly contains action states, flows (a.k.a edges
and transitions), forks, merges, joins, decisions and
objects.
• Decisions…
– are used to show alternate flows of control.
– is represented as a diamond. Outgoing transitions are
labeled with guard conditions.
3
Terms and Concepts
• Forking and Joining
– A fork is when a single flow of control splits into two or
more parallel (concurrent) flows of control.
– A join is when two or more flows of control merge into
a single flow of control.
– A flow of control is also known as a thread.
– A synchronization bar is used to model forking and
joining, and is modeled as a thick horizontal or vertical
bar.
4
A Simple
Activity
Diagram
Figure 11.1
5
Decomposing an Action
• Actions can be decomposed into subactivities
– Used as a way to manage complexity
– Indicated by the rake symbol
6
The Activity
Diagram of
Figure 11.1
modified to
invoke the
activity in figure
11.2
7
Partitions (a.k.a. Swimlanes)
• Partitions...
– Are used to group actions according to the organization
or class responsible for those actions.
– Are divided by solid vertical lines.
– Can be used in the context of concurrency.
• An activity can only belong to one partition, but
transitions between actions may cross partitions.
8
Activity Diagram
with Partitions
9
Receiving Signals
• A signal is an event received from an outside
process.
• The receipt of the signal triggers the start of an
activity
10
Sending Signals
The activity sends a signal (send itinerary) and
then concurrently waits for two separate external
signals. The first flow to reach the final state will
terminate the other flow.
11
Tokens
“Control flow is modeled in terms of tokens.
The start node will create a token which
then goes to next action. After the action
executes, the token will go to the next
action. When it encounters a fork, the fork
will create a token for each of its outbound
flows. The opposite happens for joins. It
will produce an outbound token once all
inbound tokens arrived.” -http://edutechwiki.unige.ch/en/UML_activity_diagram
12
Four Ways of Showing an Edge
(an edge is another name for transition)
The last two examples are passing an Order
object from Receive Invoice to Make Payment
13
Pins and Transformations
• Actions can have parameters
• Parameters can be modeled as pins
• Pins correspond to the parameter boxed on a decomposed
diagram
• Transformations can be used to ensure arguments match
parameters
14
Expansion Region
• An expansion region marks an activity diagram area where
actions occur once for each item in a collection
• Once all of the reviewed articles have been placed in the
list box pin, a single token is passed to Publish Newsletter
• <<concurrent>> or <<iterative>> stereotypes are
commonly used
15
Expansion Region
• Prepare Article is a shorthand notation for the expansion
region in figure 11.9
• <<concurrent>> expansion is assumed by default
16
Flow Finals
• Within an expansion
region a final flow
indicates the end of a
particular flow with out
termination the
remaining flows.
• The number of items in
the output collection
may be less than the
number of items in the
input collection
17
Join Specification
• A join specification is a Boolean expression attached to a
join
• Each time a token arrives at the join, the join specification
is evaluated
18
Objects and Activity Diagrams
• Object Flow
– Objects may be attached (using dependencies) to
specific activities in an activity diagram.
– The activity to which an object is connected has a direct
effect on the object’s state or lifetime.
– An object’s state may be shown in brackets inside the
object rectangle.
19
Activity
Diagram
with Object
Flow Using
UML 1
Notation
20
Download