25
1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

  • View
    215

  • Download
    2

Embed Size (px)

Citation preview

Page 1: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

11

CS 426Senior Projects

Chapter 14: Activity Diagrams[Arlow and Neustadt, 2005]

February 17, 2009

Page 2: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

22

Outline

Activity diagrams: Introduction ActivitiesNodes

Action nodesControl nodes Object nodes

Activity parametersPins

Page 3: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

33

Introduction Chapter roadmapChapter roadmap

Page 4: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

44

Introduction

Activity diagrams:Activity diagrams: A form of “OO flowcharts”A form of “OO flowcharts” In UML 1 they were special cases of state machines; in In UML 1 they were special cases of state machines; in

UML 2 they have completely new semantics, based on UML 2 they have completely new semantics, based on Petri Nets. Advantages:Petri Nets. Advantages:

Greater flexibility to model different types of flowGreater flexibility to model different types of flow Clear distinction between activity diagrams and state Clear distinction between activity diagrams and state

machinesmachines Attached to modeling elements to describe behaviorAttached to modeling elements to describe behavior Typically attached to use cases, classes, components, Typically attached to use cases, classes, components,

interfaces, collaborations, and operationsinterfaces, collaborations, and operations Can be used also to model business processes and Can be used also to model business processes and

workflowsworkflows

Page 5: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

55

Introduction

Commonly used in:Commonly used in: Analysis:Analysis:

To model the flow of a use caseTo model the flow of a use case To model the flow between use casesTo model the flow between use cases

Design:Design: To model the details of an operationTo model the details of an operation To model the details of an algorithmTo model the details of an algorithm

Business modeling:Business modeling: To model a business processTo model a business process

As always in modeling, it is important to keep them simple As always in modeling, it is important to keep them simple if possible, and understandable by the intended audienceif possible, and understandable by the intended audience

Page 6: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

66

Activities

Activity diagrams are networks of Activity diagrams are networks of nodesnodes connected connected by by edgesedges

NodesNodes:: Action nodes – units of work that are atomic within the Action nodes – units of work that are atomic within the

activityactivity Control nodes – control the flow through the activityControl nodes – control the flow through the activity Object nodes – represent objects used in the activityObject nodes – represent objects used in the activity

EdgesEdges:: Control flows – represent the flow of control through Control flows – represent the flow of control through

activityactivity Object flows – represent the flow of objects through activityObject flows – represent the flow of objects through activity

Page 7: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

77

Activities Activities Activities andand actions actions can have preconditions can have preconditions

and postconditionsand postconditions TokensTokens (part of semantics, but not shown (part of semantics, but not shown

graphically) flow around the network and can graphically) flow around the network and can represent:represent: The flow of controlThe flow of control An objectAn object Some dataSome data

A token moves from a source node to a target A token moves from a source node to a target node across an edge depending on:node across an edge depending on: Source node postconditionsSource node postconditions Edge guard conditionsEdge guard conditions Target node postconditionsTarget node postconditions

Page 8: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

88

Activities Example of an activity (Send letter), Fig. 14.2 [Arlow & Example of an activity (Send letter), Fig. 14.2 [Arlow &

Neustadt 2005]Neustadt 2005]

Page 9: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

99

Activities Activity diagrams can model use cases as a series of actions. Activity diagrams can model use cases as a series of actions.

Example: Fig. 14.3 and Fig. 14.4 [Arlow & Neustadt 2005]Example: Fig. 14.3 and Fig. 14.4 [Arlow & Neustadt 2005]

Page 10: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1010

Activities Activity diagrams have semantics based on Petri Nets (more Activity diagrams have semantics based on Petri Nets (more

on tehm can be found at on tehm can be found at www.daimi.au.dk/PetriNets)) They model behavior using the They model behavior using the token gametoken game Tokens are moved through the network subject to conditions Tokens are moved through the network subject to conditions

(see more on tokens on slide 7)(see more on tokens on slide 7) Object nodes represent objects flowing around the systemObject nodes represent objects flowing around the system Example of flow of control token, Fig. 14.5 Example of flow of control token, Fig. 14.5 [Arlow & Neustadt [Arlow & Neustadt

2005]2005]

Page 11: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1111

Activities Activity diagrams can be divided in Activity diagrams can be divided in partitionspartitions ( (swimlanesswimlanes) )

using vertical, horizontal or curved lines. Partitions may be using vertical, horizontal or curved lines. Partitions may be hierarchically nested. Example, Fig. 14. 6 [Arlow & Neustadt hierarchically nested. Example, Fig. 14. 6 [Arlow & Neustadt 2005]2005]

Page 12: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1212

Activities Partition hierarchies need to be organized along a Partition hierarchies need to be organized along a

dimension,dimension,Fig. 14.7 and Fig. 14.8 [Arlow & Neustadt 2005]Fig. 14.7 and Fig. 14.8 [Arlow & Neustadt 2005]

Page 13: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1313

Action nodes Action nodes execute when:Action nodes execute when:

There is a token simultaneously on each of their input There is a token simultaneously on each of their input edges ANDedges AND

The input tokens satisfy all the action node local The input tokens satisfy all the action node local preconditionspreconditions

Page 14: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1414

Action nodes After execution, the local postconditions are After execution, the local postconditions are

checked; if all are satisfied, the node checked; if all are satisfied, the node simultaneously offers tokens to all of its output simultaneously offers tokens to all of its output edges (this is an implicit fork that edges (this is an implicit fork that maymay give rise to give rise to many flows). many flows).

Naming convention, Fig. 14.10 [Arlow & Neustadt Naming convention, Fig. 14.10 [Arlow & Neustadt 2005]2005]

Page 15: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1515

Action nodes Types of action nodes, Table 14.1 Types of action nodes, Table 14.1 [Arlow & Neustadt [Arlow & Neustadt

2005]2005]

Page 16: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1616

Action nodes: Call action nodes A call action nodes invokes an activity, behavior, A call action nodes invokes an activity, behavior,

or operation, Fig. 14.11 or operation, Fig. 14.11 [Arlow & Neustadt 2005][Arlow & Neustadt 2005]

Page 17: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1717

Action nodes: Accept time event action nodes

An accept time event action node responds to An accept time event action node responds to time, Fig. 14.12 and Fig. 14.13 time, Fig. 14.12 and Fig. 14.13 [Arlow & Neustadt 2005][Arlow & Neustadt 2005]

Page 18: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1818

Control Nodes

Control nodes manage the flow of control within an Control nodes manage the flow of control within an activity, Table 14.2 activity, Table 14.2 [Arlow & Neustadt 2005][Arlow & Neustadt 2005]

Page 19: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

1919

Control Nodes

Examples of decision & merge nodes, Fig. 14.14 Examples of decision & merge nodes, Fig. 14.14 and Fig. 14.15 and Fig. 14.15 [Arlow & Neustadt 2005][Arlow & Neustadt 2005]

Page 20: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

2020

Control Nodes

Examples of join & fork nodes, Fig. 14.17 Examples of join & fork nodes, Fig. 14.17 [Arlow & [Arlow & Neustadt 2005]Neustadt 2005]

Page 21: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

2121

Object nodes Object nodesObject nodes indicate that instances of a particular indicate that instances of a particular

classifier are available at a specific point in the activity classifier are available at a specific point in the activity They are labelled with the name of the classifier and They are labelled with the name of the classifier and

represent instances of that classier or its subclassesrepresent instances of that classier or its subclasses Their input and output edges are Their input and output edges are object flowsobject flows The object flows are special types of flows that describe The object flows are special types of flows that describe

movement of objects within the activitymovement of objects within the activity The The objects objects are created and consumed by action nodesare created and consumed by action nodes When an object node received an object token on one When an object node received an object token on one

of its input edges, it offers this token to all of its output of its input edges, it offers this token to all of its output edges, and these objects edges, and these objects competecompete for the token. The for the token. The first edge that accepts the token gets it.first edge that accepts the token gets it.

Page 22: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

2222

Object nodes Object node notation & their buffer semantics Figs.

14.18, 20, and 21 [Arlow & Neustadt 2005]. Object nodes act as buffers – places in the activity diagram where object tokens can reside while waiting to be accepted by other nodes (via edges).

Page 23: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

2323

Object nodes Examples of using object nodes: Figs. 14.19 and 14.22

[Arlow & Neustadt 2005]. Note that object nodes can represent objects in particular states.

Page 24: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

2424

Activity parameters Activities can have object nodes to provide inputs and

outputs: Fig. 14.23 [Arlow & Neustadt 2005].

Page 25: 1 CS 426 Senior Projects Chapter 14: Activity Diagrams [Arlow and Neustadt, 2005] February 17, 2009

2525

Pins Pins can be used to simplify activity diagrams that use

many object nodes A pin is an object node that represents one input to or

output from an action node. Figs 14.23 and 14.25 [Arlow & Neustadt 2005].