UML ACTIVITY Dr. Hoang Huu Hanh, OST – Hue University DIAGRAMS hanh-at-hueuni.edu.vn
Hue University
e University 1
Objectives To
read and write UML activity diagrams To know when and how to use activity diagrams
e University 2
Topics Processes
and process descriptions Activity diagram notation Activity diagram execution model Making activity diagrams
e University 3
Processes and Their Description
ss ssisisaa collection collectionof of related relatedtasks tasksthat that transforms transformsaaset set of of inputs inputsinto intoa
Process description notations describe design processes as well as computational processes we design.
activity activitydiagram diagram shows showsactions actionsand andthe theflow flowof of control controland and data data betw bet
e University 4
Activities and Actions
An Anactivity activityisisaa non-atomic non-atomic task taskor or procedure proceduredecomposable decomposableinto into act ac
An Anaction actionisisaatask taskor or procedure procedurethat thatcannot cannotbe bebroken brokeninto intoparts. parts.
e University 5
Activity Graph Elements Do Laundry Sort Clothes Wash Whites
Wash Darks Dry Clothes Fold Clothes
e University 6
Execution Model Execution
is modeled by tokens that are produced by action nodes, travel over action edges, and are consumed by action nodes. When there is a token on every incoming edge of an action node, it consumes them and begins execution. When an action node completes execution, it produces tokens on each of its outgoing edges. An initial node produces a token on each e University outgoing edge when an activity 7 begins.
Branching Nodes Dry Clothes
Run Drier [still wet] [else] Fold Clothes
e University 8
Branching Execution If
a token is made available on the incoming edge of a decision node, the token is made available on the outgoing edge whose guard is true. If a token is available on any incoming edge of a merge node, it is made available on its outgoing edge. e University Guards must be mutually exclusive.
9
Deadlock
e University
RunDrier cannot execute: when the activity begins, there is a token on the edge from the initial node but not on the other incoming
Try to Dry Clothes Run Drier [still wet] [else] Fold Clothes
10
Forking and Joining Nodes Do Laundry Sort Clothes
Wash Whites
Wash Darks
Dry Clothes Fold Clothes
e University 11
Forking and Joining Execution A
token available on the incoming edge of a fork node is reproduced and made available on all its outgoing edges. When tokens are available on every incoming edge of a join node, a token is made available on its outgoing edge. Concurrency can be modeled e University without these nodes. 12
Object Nodes
Data and objects are shown as object nodes. Cruiser
Battleship [damaged]
Battlegroup
Destroyer [captured]
e University 13
Control and Data Flows Control
tokens do not contain data, object tokens do. A control flow is an activity edge that is a conduit for control tokens. A object flow is an activity edge that is a conduit for object tokens. Rules for token flow through nodes apply to both control and object tokens, except that object is extracted from consumed tokens and added to produced tokens. e University 14
Control and Data Flow Example Wash and Dry Clothes Wash Clothes Clothes [wet]
Run Drier
Clothes [still wet] [else] Fold Clothes
e University 15
Activity Parameters Activity
parameters are object nodes placed on activity symbol boundaries to indicate data or object inputs or outputs. Activity parameters contain the data or object name. Activity parameter types are specified in the activity symbol beneath the activity name.
e University 16
Activity Parameter Example FindMax a : int[1..*] max : int a
max = a[0] i=1
[else] [i < a.length] [else] [max < a.[i]] max = a[i]
max
i++
e University 17
he t n Activity Diagram Heuristics w o d ts c h t e i j b w . t o s d righ ion n t a to c l a o ft r t d n n e n u l a o co nd n s e w h i a t t o i i l a n v s. w t i F age t a s c e a d e p a s c d d a e o r e n n h n a m o l a b p ect l o a N r w r j t e b n g v o o o n l i f c r e . e a s h t t m se t a n a o e d b a N r s a e h e e s p d n d i u e o rov t h ’ n n s w b. l l p o a D n t ca w e jo y a o r e University l h . f e t h y e l v t t e re nod ren t u do a s r 18 n d e u
When to Use Activity Diagrams
When making a dynamic model of any process.
◦ Design processes (what designers do) ◦ Designed processes (what designers create) During analysis During resolution
e University 19
A pr th oce ou at t ss i UM tp ran s a L a uts sfo co de c . rm lle t p an ic ivit s a ctio Ac d tin y d se n o tiv da g a ia to fr g co ity ta c f i ela ns sy be tion ram np te ◦ a ist m tw s sm ut d a c e i b s t ta n ◦ a tio n g e o o d n ls de o sk n c o t t t a ◦ d s co f he he l p ion no s nt m fl ro et ◦ s ata ed des a o . of in w ces pe no ge of se ac cia de s Ac a tiv co s b tiv cti l n s ity nt pr ity viti ode y r e o o gr l so ce dia s, b s fo a ftw ss gr ph ra r s t n s ar an am ch art e d s c ing ing d a e University es re an , fo an ig us re rk d n. ef pr ing sto 20 u p , e
Summary