Lecture 13: Statechart Diagrams Activity Diagrams - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

Lecture 13: Statechart Diagrams Activity Diagrams

Description:

Sylnovie Merchant, Ph.D. MIS 160 2002. Object Behavior. Help to further describes functional requirements. Description of the actions an ... Waits for an event ... – PowerPoint PPT presentation

Number of Views:239
Avg rating:3.0/5.0
Slides: 40
Provided by: sylnovie
Category:

less

Transcript and Presenter's Notes

Title: Lecture 13: Statechart Diagrams Activity Diagrams


1
Lecture 13Statechart DiagramsActivity Diagrams
MIS 160 Systems Development Life Cycle I
2
Object Behavior
  • Help to further describes functional requirements
  • Description of the actions an object performs
  • Defines object responses to messages --object
    behavior

3
Statechart Diagrams
  • Shows all possible states for an object and the
    events that cause the object to change states
  • Create a SD for every object that has clearly
    identifiable states
  • Shows the (interesting) behavior of a single
    object across many use cases

4
Components of Statechart Diagrams
  • Always have
  • States
  • Events
  • Transitions
  • Actions
  • Activities
  • May also have
  • Guards
  • Synchronization bars
  • Decision psuedostates

5
Statechart Diagram Symbols
A STATE AN INITIAL STATE A FINAL
STATE AN EVENT A TRANSITION
anEvent
6
States
  • A condition during the life of an object
  • A form or mode of being
  • Satisfies a criteria
  • Performs an action
  • Waits for an event
  • Defined by the set of values currently held by
    its attributes and by its established behaviors
  • Transition
  • Mechanism that causes an object to leave one
    state and change to a new state

7
Event
  • Something being done to the object
  • Causes an object to change states
  • Only 1 event can move an object from state 1 to
    state 2

8
A VERY Simple Example A Printer
States
OnButtonPushed
Off
On
Transition
Event
9
Actions
  • Something that the object does
  • Occurs in direct response (reaction) to an event
    before moving to a state
  • Action-expression
  • Procedural statement describing action performed
  • Executes when the transition fires

10
Another VERY Simple Example A Printer
Working
Load sheet Print sheet Eject sheet
OnButtonPushed
Idle
Actions
11
Activities
  • Associated with states
  • Entry - things that happen on entry
  • Exit - things that happen on exit
  • Do - things that happen while in the state

12
and Yet Another VERY Simple Example A Printer
Working
entry/Load sheet Do/Print sheet Exit/Eject sheet
OnButtonPushed
Idle
13
Guards
  • Guard condition
  • A logical condition that returns only true or
    false
  • Can be used for events, actions, and activities

14
A VERY Simple Example A Printer
Guard
Working
OnButtonPushed Safety cover closed/statusself-
test()
Load sheet Print sheet Eject sheet
Idle
15
Decision Psuedostate
  • A decision point in the path of a statechart
    diagram

Working
OnButtonPushed
Load sheet Print sheet Eject sheet
Paper tray filled
Idle
Paper tray not filled
Error
16
Building Statechart Diagrams
  • Set the context
  • Identify behaviors from your class diagram
  • look at interaction diagrams and list all
    relevant input and output messages
  • Identify the initial final, and stable states of
    the object
  • Determine the order in which the object will pass
    through stable states
  • Identify the events, actions, and guard
    conditions associated with the transitions

17
Superstate and Substate
  • States can be nested within states
  • Superstates
  • The larger (parent) state
  • Substates
  • Nested within the superstate
  • A transition is indicated to a superstate, then
    the default substate is entered

18
Example of Superstate/Substate
19
Concurrent Behavior
  • Objects can do multiple things in parallel
  • Statechart diagrams represent concurrent behavior
    with multiple paths called threads
  • Vertical bars indicate where concurrent behavior
    begins or ends

20
Concurrent Substates
21
Concurrent States with Synchronization Bar
22
Concurrent Substate
Taking MIS 160
Proposal Accepted
Project Completed
Proposal
Project
Homework
Homework Completed
23
Composite States
  • A state can be decomposed
  • into sequential substate
  • using and-relationships into the concurrent
    substates
  • using or-relationships into mutually exclusive
    disjoint substates

24
OR / AND Transitions with Synchronization Bar
25
Example of Sequential Substate
  • e.g. research proposal and research project

26
Example of Disjoint Substate
  • e.g. comprehensive exam or masters thesis /
    project

27
Pros and Cons of State Diagrams
  • Pros
  • Gives a good sense of what events should occur
    and what effects they may have on the objects.
  • Gives a good overview of relationships within a
    system
  • Cons
  • Can get too complicated
  • Difficult to visualize the behavior of the whole
    system

28
Activity Diagrams
29
Activity Diagrams
  • Resolves the limitation of state diagrams
  • State diagram is limited limits to one object and
    only shows the behavior of the object
  • Activity diagram shows behavior of multiple
    objects and use cases
  • Show general sequence of actions for several
    objects and use cases

30
Activity Diagrams
  • Activity diagrams can be used to
  • model workflow
  • focus on activities as viewed by actors
  • often follow use case descriptions (but can be
    broader)
  • model methods
  • similar to flowcharts

31
Activity Diagram
  • Uses in connection with workflow
  • Uses in describing the behavior that has a lot of
    parallel process
  • Focus on flows driven by internal processing
  • Each activity in the diagram is a method on a
    class

32
Notation
  • Synchronization bar
  • Branch or Merge (Decision)
  • Action State
  • Transition

33
Constructing Activity Diagrams
  • For workflow
  • determine actors
  • draw in order of occurrence
  • can use branches
  • For methods
  • determine objects
  • look for computations, logic, etc.
  • can use branches

34
Example of Activity Diagram
35
Organize Actions
  • Actions may be organized into swimlanes.
  • Swimlanes are a kind of package for organizing
    responsibility for activity within a class
  • Arrange activity diagrams into vertical zones
    separated by lines

36
Example of Swimlanes
37
Action-Object Flow Relationships
  • Object flow
  • is shown by dashed arrows, which shows an input
    to or output by an action
  • Control flow
  • is shown by solid arrows, when an action produces
    an output which is an input, by a subsequent
    action. This signifies a control constraint.

38
Example-actions and object flow
39
State or Activity Diagram?
  • If you want to look at the behavior of a single
    object across many use cases, use state diagram.
  • If you want to look at behavior of multiply
    objects across many use cases or many threads,
    consider activity diagram.
Write a Comment
User Comments (0)
About PowerShow.com