State Diagrams
CSC 422
Kutztown University
Dr. Spiegel
State or Statechart
Diagrams
 Finite state machine for 1 class
 show states objects in class can be in
 show responses to external stimuli
 States
 have associated code
 can have internal finite state machines
 Transitions
 show when state changes
State Diagrams
 State diagrams are used to show possible states a
single object can get into
 shows states of an object
 How object changes state in response to events
 shows transitions between states
 UML state diagrams are a variation of Statecharts
 Statecharts are hierarchical state machines
 Statecharts have formal semantics
State Diagrams: States
 States are represented as rounded boxes which
contain:
 the state name
 and the following optional fields

entry and exit actions: entry and exit actions are executed
whenever the state is entered or exited, respectively

internal transitions: internal transitions do not activate the
entry and exit actions (different than self-transitions which
activate the entry and exit actions).

activities: Typically, once the system enters a state it sits
idle until an event triggers a transition. Activities help you to
model situations where while in a state, the object does
some work that will continue until it is interrupted by an
event

deferred events: If an event does not trigger a transition in
a state, it is lost. In situations where you want to save an
event until it triggers a transition, use deferred events
State Diagrams: States
Tracking
entry / setMode(on Track)
exit / setMode(off Track)
newTarget / tracker.Acquire()
do / followTarget
selfTest / defer
entry action
exit action
internal transition
activity
deferred event
Note that, “entry”, “exit”, “do”, and “defer” are keywords
State Diagrams: Transitions
 Transitions
 source state and target state: shown by the arrow
representing the transition
 trigger event: the event that makes the transition fire
 guard condition: a boolean expression that is evaluated
when the trigger event occurs, the transition can fire
only if the guard condition evaluates to true
 action: an executable atomic computation that can
directly act on the object that owns the state machine or
indirectly on other objects that are visible to the object
 initial and final states: shown as filled circle and a filled
circle surrounded by an unfilled circle, respectively
trigger-event[guard-condition]/action
source state target state
State Diagrams
Checking
do / checkItem
/ getFirstItem
shows the initial (default) state
cancelled
getNextItem
[not all items checked]
shows the final state
State Diagram Example:
Order Object
Dispatching
do: delivery
Delivered
Initial State
Waiting
/getFirstItem
Checking
do: checkItem
[stillMore] / getNextItem
Delivered
[AllItemsChecked &&
AllItemsAvailable ]
[AllItemsCheck &&
SomeNotAvailable ]
ItemReceived
[SomeNotAvailable]
ItemReceived
[AllItemsAvailable]
Example with Cancelled
State
Dispatching
do: delivery
Delivered
Initial State
Waiting
/getFirstItem
Checking
do: checkItem
[stillMore] / getNextItem
Delivered
[AllItemsChecked &&
AllItemsAvailable ]
[AllItemsCheck &&
SomeNotAvailable ]
ItemReceived
[SomeNotAvailable]
Cancelled
Cancel
Cancel
Cancel
ItemReceived
[AllItemsAvailable]
Example: Add Super State
Delivered
/getFirstItem
[AllItemsCheck &&
SomeNotAvailable ]
Waiting
ItemReceived
[SomeNotAvailable]
Checking
do: checkItem
[stillMore] / getNextItem
Dispatching
do: delivery
Delivered
[AllItemsChecked &&
AllItemsAvailable ]
Cancelled
Cancel
Active
ItemReceived
[AllItemsAvailable]
Concurrent State Diagrams
 Order object of example also has states
associated with the payment authorization
 Could Authorize between
Dispatching and
Delivery. Not nice.
 Concurrency better
 system in 2 states
while in concurrent
mode
Authorized
[Payment OK]
Authorizing
do: checkPmt
Rejected
[Payment not
OK]
Delivered
deliver
Concurrency Example
Order Object
Waiting
Checking Dispatching
Authorizing Authorized
Rejected
Cancelled
cancel
end
Delivered
delivered
Concurrency Example (cont)
 Inside the concurrency block the Order object
is in 2 states; when it leaves it is only in one
 Order object starts out in both the Checking
and Authorizing states
 If the Authorizing:checkPmt step finishes first
 if successful, state is Authorized and Checking
 else exit concurrent phase to Rejected
 else could be Authorizing/Waiting or
Authorizing/Dispatching and so on.

More Related Content

PPT
State Diagrams
PDF
Free ebooks download ! Edhole
PDF
Free ebooks download ! Edhole
PPT
Seminar State Chart1
PPTX
events and signals in Unified modelling language
DOCX
States machine
PPTX
Advanced behavioral modeling chapter 4 of omd
PPTX
483-Final-Harel_ Statechart & UML.pptx
State Diagrams
Free ebooks download ! Edhole
Free ebooks download ! Edhole
Seminar State Chart1
events and signals in Unified modelling language
States machine
Advanced behavioral modeling chapter 4 of omd
483-Final-Harel_ Statechart & UML.pptx

Similar to StateDiagrams (Unified modeling Languages) (20)

PPT
08 state diagram and activity diagram
PPT
States and Activities
PPTX
STATE DIAGRAM.pptx
PPTX
state modeling In UML
PPTX
State modeling
PPT
State Machine Diagram
PDF
CS8592-OOAD Lecture Notes Unit-3
PDF
Software Engineering :Behavioral Modelling - II State diagram
PPT
5. state diagrams
 
PPT
5.state diagrams
 
PPT
C:\documents and settings\student\desktop\swaroop uml
PPTX
PPT
Jar chapter 4, part 1
PPTX
Activity Diagram, State Transition Diagram, Collaboration Diagram
PPTX
Unit III Dynamic and Implementation UML Diagrams.pptx
PPTX
Generation of state diagram from time chart
PPTX
State-Machine-Diagram.pptx
PPTX
Diagrams
PPTX
Data Flow Diagram.pptx
08 state diagram and activity diagram
States and Activities
STATE DIAGRAM.pptx
state modeling In UML
State modeling
State Machine Diagram
CS8592-OOAD Lecture Notes Unit-3
Software Engineering :Behavioral Modelling - II State diagram
5. state diagrams
 
5.state diagrams
 
C:\documents and settings\student\desktop\swaroop uml
Jar chapter 4, part 1
Activity Diagram, State Transition Diagram, Collaboration Diagram
Unit III Dynamic and Implementation UML Diagrams.pptx
Generation of state diagram from time chart
State-Machine-Diagram.pptx
Diagrams
Data Flow Diagram.pptx
Ad

Recently uploaded (20)

PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PPTX
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
Computer System Architecture 3rd Edition-M Morris Mano.pdf
PPTX
mechattonicsand iotwith sensor and actuator
PPTX
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
PDF
Computer organization and architecuture Digital Notes....pdf
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PDF
Cryptography and Network Security-Module-I.pdf
PPTX
CONTRACTS IN CONSTRUCTION PROJECTS: TYPES
PPT
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
DOC
T Pandian CV Madurai pandi kokkaf illaya
PDF
Java Basics-Introduction and program control
PDF
Soil Improvement Techniques Note - Rabbi
PDF
First part_B-Image Processing - 1 of 2).pdf
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PDF
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
Exploratory_Data_Analysis_Fundamentals.pdf
Computer System Architecture 3rd Edition-M Morris Mano.pdf
mechattonicsand iotwith sensor and actuator
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
Computer organization and architecuture Digital Notes....pdf
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
Cryptography and Network Security-Module-I.pdf
CONTRACTS IN CONSTRUCTION PROJECTS: TYPES
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
T Pandian CV Madurai pandi kokkaf illaya
Java Basics-Introduction and program control
Soil Improvement Techniques Note - Rabbi
First part_B-Image Processing - 1 of 2).pdf
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
Ad

StateDiagrams (Unified modeling Languages)

  • 1. State Diagrams CSC 422 Kutztown University Dr. Spiegel
  • 2. State or Statechart Diagrams  Finite state machine for 1 class  show states objects in class can be in  show responses to external stimuli  States  have associated code  can have internal finite state machines  Transitions  show when state changes
  • 3. State Diagrams  State diagrams are used to show possible states a single object can get into  shows states of an object  How object changes state in response to events  shows transitions between states  UML state diagrams are a variation of Statecharts  Statecharts are hierarchical state machines  Statecharts have formal semantics
  • 4. State Diagrams: States  States are represented as rounded boxes which contain:  the state name  and the following optional fields  entry and exit actions: entry and exit actions are executed whenever the state is entered or exited, respectively  internal transitions: internal transitions do not activate the entry and exit actions (different than self-transitions which activate the entry and exit actions).  activities: Typically, once the system enters a state it sits idle until an event triggers a transition. Activities help you to model situations where while in a state, the object does some work that will continue until it is interrupted by an event  deferred events: If an event does not trigger a transition in a state, it is lost. In situations where you want to save an event until it triggers a transition, use deferred events
  • 5. State Diagrams: States Tracking entry / setMode(on Track) exit / setMode(off Track) newTarget / tracker.Acquire() do / followTarget selfTest / defer entry action exit action internal transition activity deferred event Note that, “entry”, “exit”, “do”, and “defer” are keywords
  • 6. State Diagrams: Transitions  Transitions  source state and target state: shown by the arrow representing the transition  trigger event: the event that makes the transition fire  guard condition: a boolean expression that is evaluated when the trigger event occurs, the transition can fire only if the guard condition evaluates to true  action: an executable atomic computation that can directly act on the object that owns the state machine or indirectly on other objects that are visible to the object  initial and final states: shown as filled circle and a filled circle surrounded by an unfilled circle, respectively trigger-event[guard-condition]/action source state target state
  • 7. State Diagrams Checking do / checkItem / getFirstItem shows the initial (default) state cancelled getNextItem [not all items checked] shows the final state
  • 8. State Diagram Example: Order Object Dispatching do: delivery Delivered Initial State Waiting /getFirstItem Checking do: checkItem [stillMore] / getNextItem Delivered [AllItemsChecked && AllItemsAvailable ] [AllItemsCheck && SomeNotAvailable ] ItemReceived [SomeNotAvailable] ItemReceived [AllItemsAvailable]
  • 9. Example with Cancelled State Dispatching do: delivery Delivered Initial State Waiting /getFirstItem Checking do: checkItem [stillMore] / getNextItem Delivered [AllItemsChecked && AllItemsAvailable ] [AllItemsCheck && SomeNotAvailable ] ItemReceived [SomeNotAvailable] Cancelled Cancel Cancel Cancel ItemReceived [AllItemsAvailable]
  • 10. Example: Add Super State Delivered /getFirstItem [AllItemsCheck && SomeNotAvailable ] Waiting ItemReceived [SomeNotAvailable] Checking do: checkItem [stillMore] / getNextItem Dispatching do: delivery Delivered [AllItemsChecked && AllItemsAvailable ] Cancelled Cancel Active ItemReceived [AllItemsAvailable]
  • 11. Concurrent State Diagrams  Order object of example also has states associated with the payment authorization  Could Authorize between Dispatching and Delivery. Not nice.  Concurrency better  system in 2 states while in concurrent mode Authorized [Payment OK] Authorizing do: checkPmt Rejected [Payment not OK] Delivered deliver
  • 12. Concurrency Example Order Object Waiting Checking Dispatching Authorizing Authorized Rejected Cancelled cancel end Delivered delivered
  • 13. Concurrency Example (cont)  Inside the concurrency block the Order object is in 2 states; when it leaves it is only in one  Order object starts out in both the Checking and Authorizing states  If the Authorizing:checkPmt step finishes first  if successful, state is Authorized and Checking  else exit concurrent phase to Rejected  else could be Authorizing/Waiting or Authorizing/Dispatching and so on.