UML ActivityDiagram

download UML ActivityDiagram

of 20

Transcript of UML ActivityDiagram

  • 8/14/2019 UML ActivityDiagram

    1/20

    1

    University

    Hue UniversityHue University

    UMLUMLACTIVITYACTIVITYDIAGRAMSDIAGRAMS

    . , Dr Hoang Huu Hanh OST Hue University

    hanh-at-hueuni.edu.vn

  • 8/14/2019 UML ActivityDiagram

    2/20

    2

    University

    ObjectivesObjectives

    To read and write UML activitydiagrams

    To know when and how to use

    activity diagrams

  • 8/14/2019 UML ActivityDiagram

    3/20

  • 8/14/2019 UML ActivityDiagram

    4/20

    4

    University

    Processes and TheirProcesses and TheirDescriptionDescription

    Process description notationsdescribe design processes as well ascomputational processes we design.

    ss is a collection of related tasks that transforms a set of inputs intos is a collec

    tion of related tasks that transforms a set of inputs into

    activity diagram shows actions and the flow of control and data bectivity diag

    ram shows actions and the flow of control and data bet

  • 8/14/2019 UML ActivityDiagram

    5/20

    5

    University

    Activities and ActionsActivities and Actions

    An activity is a non-atomic task or procedure decomposable into a

    An action is a task or procedure that cannot be broken into parts.

    n activity is

    a non-atomic task or procedure decomposable into ac

    n action is a task or procedure that cannot be broken into parts.

  • 8/14/2019 UML ActivityDiagram

    6/20

    6

    University

    Activity Graph ElementsActivity Graph Elements

    Sort

    Clothes

    Wash

    Whites

    Wash

    Darks

    Dry

    Clothes

    FoldClothes

    Do Laundry

  • 8/14/2019 UML ActivityDiagram

    7/207

    University

    Execution ModelExecution Model

    Execution is modeled by tokens that areproduced by action nodes, travel overaction edges, and are consumed byaction nodes.

    When there is a token on everyincoming edge of an action node, itconsumes them and begins execution.

    When an action node completesexecution, it produces tokens on eachof its outgoing edges.

    An initial node produces a token on each

    outgoing edge when an activitybegins.

  • 8/14/2019 UML ActivityDiagram

    8/208

    University

    Branching NodesBranching Nodes

    Run Drier

    Fold

    Clothes

    Dry Clothes

    [else]

    [still wet]

  • 8/14/2019 UML ActivityDiagram

    9/209

    University

    Branching ExecutionBranching Execution

    If a token is made available onthe incoming edge of a decisionnode, the token is made

    available on the outgoing edgewhose guard is true.

    If a token is available on anyincoming edge of a merge node,it is made available on itsoutgoing edge.

    Guards must be mutually

    exclusive.

  • 8/14/2019 UML ActivityDiagram

    10/2010

    University

    DeadlockDeadlock

    RunDriercannot

    execute: whenthe activitybegins, there isa token on the

    edge from theinitial node butnot on the

    other incoming

    Run Drier

    Fold

    Clothes

    Try to DryClothes

    [else]

    [still wet]

  • 8/14/2019 UML ActivityDiagram

    11/2011

    University

    Forking and Joining NodesForking and Joining Nodes

    SortClothes

    WashWhites

    WashDarks

    DryClothes

    Fold

    Clothes

    Do Laundry

  • 8/14/2019 UML ActivityDiagram

    12/2012

    University

    Forking and JoiningForking and JoiningExecutionExecutionA token available on the incoming

    edge of a fork node isreproduced and made available

    on all its outgoing edges.When tokens are available on

    every incoming edge of a joinnode, a token is made availableon its outgoing edge.

    Concurrency can be modeledwithout these nodes.

  • 8/14/2019 UML ActivityDiagram

    13/2013

    University

    Object NodesObject Nodes

    Data and objects are shown asobject nodes.

    Destroyer[captured]

    Cruiser

    Battlegroup

    Battleship[damaged]

  • 8/14/2019 UML ActivityDiagram

    14/2014

    University

    Control and Data FlowsControl and Data Flows

    Control tokens do not contain data,object tokens do.

    A control flow is an activity edge thatis a conduit for control tokens.

    A object flow is an activity edge thatis a conduit for object tokens.

    Rules for token flow through nodes

    apply to both control and objecttokens, except that object isextracted from consumed tokens andadded to produced tokens.

  • 8/14/2019 UML ActivityDiagram

    15/2015

    University

    Control and Data FlowControl and Data Flow

    ExampleExample

    Run Drier

    Fold

    Clothes

    Wash and DryClothes

    [else]

    [still wet]

    Clothes

    [wet]

    Clothes

    Wash

    Clothes

  • 8/14/2019 UML ActivityDiagram

    16/2016

    University

    Activity ParametersActivity Parameters

    Activity parameters are objectnodes placed on activity symbolboundaries to indicate data or

    object inputs or outputs.Activity parameters contain the

    data or object name.

    Activity parameter types arespecified in the activity symbolbeneath the activity name.

  • 8/14/2019 UML ActivityDiagram

    17/2017

    University

    Activity ParameterActivity ParameterExampleExample

    max = a[i]

    FindMaxa : int[1..*]

    max : int

    [else]

    [i < a.length]

    i++

    [max < a.[i]]

    [else]

    max = a[0]i = 1

    a

    max

  • 8/14/2019 UML ActivityDiagram

    18/2018

    University

    Activity Diagram HeuristicsActivity Diagram Heuristics

    Flowc

    ontrol

    andobje

    ctsdo

    wnth

    e

    pageand

    leftto

    right.

    Nam

    eactivities

    anda

    ctionswit

    h

    verbp

    hrases.

    Nameo

    bjectn

    odeswithn

    oun

    phrases.

    Don

    tusebot

    hcont

    roland

    data

    flowsw

    henadat

    aflow

    alone

    can

    dothe

    job.

    esureth

    atall

    nodesent

    ering

    onnodec

    anpro

    vide

    urrently.

    datever

    y

  • 8/14/2019 UML ActivityDiagram

    19/20

    19

    University

    When to Use ActivityWhen to Use ActivityDiagramsDiagramsWhen making a dynamic model ofany process.

    Design processes (what designers

    do) Designed processes (what

    designers create) During analysisDuring resolution

    A

  • 8/14/2019 UML ActivityDiagram

    20/20

    20

    University

    SummarySummary

    Aprocessisacollectionofrelate

    dtasks

    thattran

    sformsasetofinp

    utstoaseto

    outputs.

    UM

    Lactivitydiagram

    smodelprocessesby

    depictingactionsandtheflowofc

    ontrol

    anddatabetweenthem

    .

    Activitysymbolscontainact

    ivitygraphs

    cons

    istingof

    actionnodes

    actionedges

    datanodes

    specialnodesforstartingan

    dstop

    activities,branching,fo

    rking

    Activitydiagram

    scanrepr

    processandareusef

    softwaredesign.