uml activity diagrams 2
TRANSCRIPT
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 1/44
1
Activity diagrams inUML 2.0
Hoang Huu Hanh
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 2/44
2
Contents
l Introduction to UML 2.0 Activity Diagramsl Concepts of Action, Pins and Activityl Description of activity nodes and activity edgesl New notations
l ActivityPartitionl Pre & post conditionl SendSignalActionl Time triggers and Time eventsl
AcceptEventActionl InterruptibleActivityRegionl Exceptionl ExpansionRegion
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 3/44
3
Activity diagrams
l Useful to specify software or hardware system behaviour
l Based on data flow models – a graphical representation(with a Directed Graph) of how data move around aninformation system
Fill
Order
Ship
Order
Send
Invoice
Accept
Payment
Close
Order
Make Payment
[order accepted]
Invoice
Receive
Order
[order reject]
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 4/44
4
Some definitions
l Flow : permits the interaction between two nodes of theactivity diagram (represented by edges in activity diagram)
l State: a condition or situation in the life of an object duringwhich it satisfies some conditions, performs some
activities, or waits for some eventsl Type: specifies a domain of objects together with the
operations applicable to the objects (also none); includesprimitive built-in types (such as integer and string) andenumeration types
l Token: contains an object, datum, or locus of control, and ispresent in the activity diagram at a particular node; eachtoken is distinct from any other, even if it contains the samevalue as another
l Value: an element of a type domain
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 5/44
5
Actions
l The fundamental unit of executablefunctionality in an activity
l The execution of an action represents some
transformations or processes in themodeled system (creating objects, settingattribute values, linking objects together,invoking user-defined behaviours, etc.)
Description of the actionbehaviour
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 6/44
6
Pinsl Actions can have inputs and outputs, through the pinsl Hold inputs to actions until the action starts, and hold the
outputs of actions before the values movedownstream
l The name of a pin is not restricted: generally recalls thetype of objects or data that flow through the pin
Output pinsStandalone pin notations:
the output pin and theinput pin have the same
name and same type
Input pins
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 7/44
7
Special kind of pins (1)l Streaming Parameters (notated with {STREAM}): accept or
provide one or more values while an action is executingl
l
l
l
l
l
l
l Exception Output Parameters (notated with a triangle)l Provide values to the exclusion of any other output
parameter or outgoing control of the actionl The action must immediately terminate, and the output
cannot quit
Stand-alonestyle
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 8/44
8
Special kind of pins (2)
l Parameter Setsl group of parametersl the action can only accept inputs
from the pins in one of the setsl
the action can only provide outputs to the pins in one of the sets
l
l
l
l ValuePin: special kind of input pin defined to provide constantvalues (the type of specificated value must be compatible withthe type of the value pin)
π
Computecircumference3.14
Ray
value
Output is provided only tothe first or to the second set
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 9/44
9
Conditions to start and end actions
l An action can start only if:l all non-stream inputs have arrived (or at least
one stream input if there are only streaminputs)
l The action can finish only if:l all inputs have arrived (streaming inputs
included)l all non-stream and non-exception outputs (or
an exception outputs) have been providedl
l Prevent deadlock : an input pin of an actioncannot accept tokens until all the input pins of the action can accept them
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 10/44
10
Parameter name
Parameter name Parameter
nameOutput
parameter
Activitynodes
ActivityedgesInput
parameter
Activities
l An activity is the specification of parameterized behaviour as thecoordinated sequencing of subordinate units whose individualelements are actions
l Uses parameters to receive and provide data to the invoker
lAn action can invoke an activity to describe its action more finely
This action invokes
the activity Fill Order
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 11/44
11
Activity nodesl Three type of activity nodes:
l Action nodes: executable activity nodes; theexecution of an action represents sometransformations or processes in the modeledsystem (already seen)
l
l
l Control nodes: coordinate flows in an activitydiagram between other nodes
l
l
l
l Object nodes: indicate an instance of a particular object, may be available at a particular point in theactivity (i.e Pins are object nodes)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 12/44
12
Activity edges (1)
l Are directed connectionsl They have a source and a target, along which tokens
may flowl
l
l Any number of tokens can pass along the edge, ingroups at one time, or individually at different times
l Weight : determines the minimum number of tokens that
must traverse the edge at the same time
In this example we use a non-constant weight: an invoice for a particular job can only be sent when all of its tasks have been completed
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 13/44
13
Activity edges (2)
l Two kinds of edges:
l Control flow edge - is an edge which starts anactivity node after the completion of the
previous one by passing a control tokenl
l
l Object flow edge - models the flow of values to
or from object nodes by passing object or datatokens
Notation withoutactivity nodes
Notation withoutactivity nodes
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 14/44
14
Options
l Object nodesl multiplicities and upperBound
l effect and ordering
l Activity nodesl presentation options
l transformation
l Selectionl Token competion
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 15/44
15
New notations
l ActivityPartition
l Pre & post condition
l SendSignalAction
l Time triggers and Time events
l AcceptEventAction
l InterruptibleActivityRegion
l Exception
l ExpansionRegion
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 16/44
16
Example – go to Genova
Getluggage
ready
[on car]
[on train]
«local precondition»Have a license
Turn onthe car
Tomotorway
tollgate
Exit toGenovatollgate
Go homewith the
car
Go to thestation with
a friend
Buy theticket
Obliteratethe ticket
Catchthe train
When the trainarrives
to Genova
Get off the train
The trainderail
Car crash
The friendgoes home
Go homewith bus
Go toHeaven/Hell
;)
Go toHeaven/
Hell ;)
Studyfor 5
minutes
[Genova is a long way]
[else]
Catchthe
ticket
Fill upwithfuel
[the tank is full]
[else]
Pay theticket
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 17/44
17
Bibliography
l Object Management Group, “UML 2.0 Superstructure Specification,”http://www.omg.org/cgi-bin/doc?ptc/03-08-02, August 2003
l Conrad Bock (U.S. NIST), “UML 2 Activity and Action Models,” inJournal of Object Technology , vol. 2, no. 4, July-August 2003,pp. 43-53, http://www.jot.fm/issues/issue_2003_07/column3
l
Conrad Bock (U.S. NIST), “UML 2 Activity and Action Models, Part2: Actions,” in Journal of Object Technology , vol. 2, no. 5,September-October 2003, pp. 41-56,http://www.jot.fm/issues/issue_2003_09/column4
l Conrad Bock (U.S. NIST), “UML 2 Activity and Action Models, Part3: Control Nodes,” in Journal of Object Technology , vol. 2, no. 6,November-December 2003, pp. 7-23,
http://www.jot.fm/issues/issue_2003_11/column1l Conrad Bock (U.S. NIST), “UML 2 Activity and Action Models, Part
4: Object Nodes,” in Journal of Object Technology , vol. 3, no. 1,January-February 2004, pp. 27-41,http://www.jot.fm/issues/issue_2003_11/column1
l Gruppo Yahoo su UML, http://groups.yahoo.com/group/uml-forum/
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 18/44
18
Control nodes – initial nodes
l In an activity the flow starts in initial nodes, that returnthe control immediately along their outgoing edges
l
l
l If there are more than one initial node, a control tokenis placed in each initial node when the activity isstarted, initiating multiple flows
l If an initial node has more than one outgoing edge,
only one of these edges will receive control,because initial nodes cannot duplicate tokens
A or B ?
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 19/44
19
Control nodes – decision nodes
l Route the flow to one of the outgoing edges (tokensare not duplicated)
l Guards are specified on the outgoing edges or withthe stereotype «decisionInput»
l There is also the predefined guard [else], chosenonly if the token is not accepted by all the other edges
l If all the guards fail, the token remains at the sourceobject node until one of the guards accept it
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 20/44
20
Control nodes – merge nodes
l Bring together multiple alternate flows
l All controls and data arriving at a merge nodeare immediately passed to the outgoing
edgel There is no synchronization of flows or joining
of tokens
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 21/44
21
Control nodes – fork nodes
l Fork nodes split flows into multiple concurrent flows(tokens are duplicated)
l
l
l
l
l
l State machine forks in UML 1.5 requiredsynchronization between parallel flows through thestate machine RTC step (it means that the first statein each branch is executed, then the second one,etc.)
l
UML 2.0 activity forks model unrestricted parallelism
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 22/44
22
Control nodes – join nodes
l Join nodes synchronize multiple flows
l
l
l
l Generally, controls or data must be available on everyincoming edge in order to be passed to the outgoing edge,but user can specify different conditions under which a joinaccepts incoming controls and data using a joinspecification
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 23/44
23
Control nodes – final nodesl
Flow final:l destroys the tokens that arrive into it
l the activity is terminated when all tokens in the graphare destroyed
l Final node:
l the activity is terminated when the first token arrives
intentional racebetween flows
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 24/44
24
Object nodesl Hold data temporarily while they wait to move through
the graphl Specify the type of values they can hold (if no type is
specified, they can hold values of any type)l Can also specify the state of the held objectsl
l
l There are four kinds of object nodes:
Pins(three differents notations)
Activity Parameter Nodes
CentralBuffer Nodes
DataStoreNodes
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 25/44
25
Object nodes – centralBuffer
l A central buffer node is an object node that managesflows from multiple sources and destinations (asopposed to pins and parameters)
l Acts as a buffer for multiple input flows and output flows
l Is not tied to an action like pins, or to an activity likeactivity parameter nodes
The centralBuffer node collects theobject Parts, and each Part can be
used or packet (but not both)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 26/44
26
Object nodes – datastorel Is a specific central buffer node which stores objects
persistentlyl Keeps all tokens that enter into itl Tokens chosen to move downstream are copied so that
tokens never leave the data store
l If arrives a token containing an object already present in thedata store, this replaces the old one
l Tokens in a data store node cannot be removed (they areremoved when the activity is terminated)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 27/44
27
Object nodes - multiplicities and upperBound
l Multiplicities: specify the minimum (≥0) and maximumnumber of values each pin accepts or provides at eachinvocation of the action:l when is available the minimum number of values, the
action can start
l if there is more values than the maximum, the actiontakes only the first maximum value
l
l
l
l UpperBound : shows the maximum number of values that anobject node can hold: at runtime, when the upper boundhas been reached, the flow is stopped (buffering)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 28/44
28
Object nodes – effect and ordering
l Effect : pins can be notated with the effect that their actions have on objects that move through the pin
l The effects can be: ‘create’ (only on output pins),‘read’, ‘update’ or ‘delete’ (only on input pins)
l
l
l
l Ordering : specifies the order in which the tokens of an object node are offered to the outgoing edges(FIFO, LIFO or modeler-defined ordering)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 29/44
29
Activity edges – presentation options
l An edge can also be notated using a connector
l Every connector with a given label must be paired with exactlyone other with the same label on the same activity diagram
is equivalent to
lTo reduce clutter in complex diagrams, object nodes may be
elided
is equivalent to
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 30/44
30
Activity edges - transformation
l It is possible to apply a transformation of tokens asthey move across an object flow edge (each order is passed to the transformation behaviour andreplaced with the result)
In this example, thetransformation gets the
value of the attributeCustomer of the Order
object
<<transformation>>
transformationspecification
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 31/44
31
Selection
l Specifies the order (FIFO, LIFO or modeler-defined ordering) inwhich tokens in the node are offered to the outgoing edges
l Can be applied to:l Object node- specifies the object node ordering, choosing
what token offers to the outgoing edge whenever it asks a
tokenl
l
l
l Edge - chooses the order on which tokens are offered from
the source object node to the edge (overrides anyselection present on the object node, that is object nodeordering)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 32/44
32
Token competition
l A parameter node or pin may have multiple edgescoming out of it, whereupon there will becompetition for its tokens, because object nodes
cannot duplicate tokens while forks canl Then there is indeterminacy in the movement of
data in the graph
If the input pin of Paint at Station1 is full, the token remains at theoutput of Make Part until thetraversal can be completed toone of the input pins
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 33/44
33
ActivityPartition (1)l Partitions divide the nodes and edges for identifying
actions that have some characteristics in commonl They often correspond to organizational units in a
business modell Partitions can be hierarchical and multidimensionall Additional notation is provided: placing the partition
name in parenthesis above the activity name
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 34/44
34
ActivityPartition (2)
Partitionnotated to
occur outsidethe primaryconcern of
the model
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 35/44
35
Pre & post condition (1)
l Can be referred to an activity or to an action (localcondition)
l
l
l
l
l
l
l UML intentionally does not specify when or whether pre/post conditions are tested (design time, runtime,etc.)
l UML also does not define what the runtime effect of afailed pre/post condition should be (error that stopsexecution, warning, no action)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 36/44
36
Pre & post condition (2)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 37/44
37
SendSignalAction
l Creates a signal instance from its inputs, andtransmits it to the target object (local or remote)
l A signal is an asynchronous stimulus that triggers a
reaction in the receiver in an asynchronous wayand without a reply
l Any reply message is ignored
l
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 38/44
38
Time triggers and Time events
l A Time trigger is a trigger that specifies when a timeevent will be generated
l Time events occur at the instant when a specified
point in time has transpiredl This time may be relative or absolute
l Relative time trigger : is specified with the keyword‘after’ followed by an expression that evaluates to atime value
l Absolute time trigger : is specified as an expressionthat evaluates to a time value
Jan, 1, 2000, Noonafter (5 seconds)
Relative time trigger Absolute time trigger
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 39/44
39
AcceptEventActionl Waits for the occurrence of an event meeting specified
conditions
l Two kinds of AcceptEventAction:
l Accept event action – accepts signal
events generated by a SendSignalActionl Wait time action – accepts time events
Accept event action
Wait time action
The objects stored inPersonnel are only
retrieved when the joinsucceeds (only once a
year)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 40/44
40
InterruptibleActivityRegionl Is an activity group (sets of nodes and edges) that supports
termination of tokens flowing into itl When a token leaves an interruptible region via interrupting
edges, all tokens and behaviours in the region are terminatedl Token transfer is still atomic: a token transition is never partial; it
is either complete or it does not happen at all (also for internalstream)
Interruptingedge
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 41/44
41
Exceptions (1)l
Exception handler - specifies the code to be executedwhen the specified exception occurs during theexecution of the protected node
l When an exception occurs the set of execution handlerson the action is examined to look for a handler that
matches (catches) the exceptionl If the exception is not caught, it is propagated to the
enclosing protected node, if one existsl If the exception propagates to the topmost level of the
system and is not caught, the behaviour of the system
is unspecified; profiles may specify what happens insuch cases
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 42/44
42
Exceptions (2)
Successful end
Protectednode withtwo nestedactivities
HandlerBodynode
l
When an exception is caught, is executed the exception bodyinstead of the protected node, and then the token is passedto all the edges that go out from that protected node
l The exception body has no explicit input or output edgesl Exception body can resolve the problems that have caused
the exception or can abort the programl We can put any activities nested in a protected node (in UML
2.0, nesting activities is allowed)
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 43/44
43
ExpansionRegion (1)
l Nested region of an activity in which each input is acollection of values
l The expansion region is executed once for each element(or position) in the input collection
l On each execution of the region, an output value fromthe region is inserted into an output collection at thesame position as the input elements
8/14/2019 UML Activity Diagrams 2
http://slidepdf.com/reader/full/uml-activity-diagrams-2 44/44
44
ExpansionRegion (2)l There are three ways of interaction between the
executions:l Parallel (concurrent): all the interactions are
independentl Iterative: the interactions occur in the order of the
elements (the executions of the region musthappen in sequence, with one finishing beforeanother can begin)
l Stream (streaming): there is a single execution of
the region, where the values in the inputcollection are extracted and placed into theexecution of the expansion region as a stream(in order if the collection is ordered)