- Forward


UML Activity Diagrams
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Overview
Back SMYC Forward
  • Purpose:
    • Describe a task/procedure/process
  • Components:
    • Activity - a non-atomic (i.e., decomposable) task
    • Action - an atomic (i.e., not decomposable) task
    • Data - inputs to or outputs from actions (and may include state information in square brackets)
    • Flow - flow of control and flow of data
Symbology
Back SMYC Forward
  • Activities:
    • activity-diagram_activity
  • Actions:
    • activity-diagram_action
  • Objects/Classes/Data:
    • activity-diagram_object
  • Flows:
    • activity-diagram_flow
Representation and Interpretation
Back SMYC Forward
  • Directed Graph:
    • Nodes/Vertexes - represent actions or objects
    • Edges/Arcs/Links - represent control flows and/or data flows
  • Tokens:
    • Produced and consumed by nodes (though not represented on the diagram)
    • Flow instantaneously along edges
  • Execution:
    • An action node begins executing when tokens are available on all incoming edges
    • When an action node begins execution it consumes all incoming tokens
    • While/after an action node executes it produces outgoing tokens
An Example
Back SMYC Forward
activity-diagram_wash-hair-1
Additional Elements
Back SMYC Forward
  • Initial Node:
    • activity-diagram_initial-node
  • Final Node:
    • activity-diagram_final-node
  • Decision Node:
    • activity-diagram_decision-node
    • One incoming edge
    • One or more outgoing edges
    • Outgoing edges can have a Boolean guard
  • Merge Node:
    • activity-diagram_decision-node
    • One or more incoming edges
    • One outgoing edge
An Example Revisited
Back SMYC Forward
activity-diagram_wash-hair-2
Why Use Merge Nodes?
Back SMYC Forward
  • Compare the Following Two Activities:
    • activity-diagram_need-for-merge
  • Hint:
    • Recall that an action does not start until the tokens on all of its incoming edges have arrived
    • Expand
Still More Elements
Back SMYC Forward
  • Pin:
    • A terminator for data flows into (input pins) or out of (output pins) an action node
  • Activity Parameter:
    • An object node on the boundary of an activity
    • Contains the name of a particular object and the name of its type
    • Syntax: Click here for information. name:type
A Larger Example
Back SMYC Forward

Courtesy of Introduction to Software Engineering and Design (Fox, 2006)

activity-diagram_do-laundary
The Larger Example with Object/Data Nodes
Back SMYC Forward
activity-diagram_do-laundary_object-nodes
Sequential and Parallel Actions
Back SMYC Forward
  • Fork Node:
    • Splits a single (incoming) flow into multiple concurrent/parallel (outgoing) flows
    • activity-diagram_fork
  • Join Node:
    • Synchronizes multiple (incoming) flows into a single (outgoing) flow
    • activity-diagram_join
An Example with Parallel Actions
Back SMYC Forward
activity-diagram_prepare-breakfast-special
Compare the Following Activity Diagrams
Back SMYC Forward
activity-diagram_do-laundary_comparison
Abstraction and Sub-Activities
Back SMYC Forward
  • Abstraction in Activity Diagrams:
    • As with any model, a decision must be made about how much detail to include
  • Associating an Activity with an Action:
    • It's possible to indicate that a sub-activity exists for an action using the following notation:
      activity-diagram_sub-activity
There's Always More to Learn
Back -