Object Oriented Software Modeling and Design  CE 350 Abdel-Karim Al-Tamimi, Ph.D. [email_address] http://faculty.yu.edu.jo...
Overview <ul><li>State Machine Diagram </li></ul>Al-Tamimi 2011 ©
State Machine Diagram <ul><li>The behavior of an entity is not only a direct consequence of its inputs, but it also depend...
What is a State? <ul><li>According to Rumbaugh et al. “ A state is an abstraction of the attribute values and links of an ...
State Characteristics <ul><li>There are several characteristics of states: </li></ul><ul><ul><li>A state occupies an inter...
State Diagrams Al-Tamimi 2011 ©
Example Al-Tamimi 2011 ©
Example Al-Tamimi 2011 ©
Composite State Al-Tamimi 2011 ©
State UML Notations Al-Tamimi 2011 © State Name Internal Activities Internal Transitions
State Conditions Al-Tamimi 2011 © Action or activity Description entry/ action 1; …; action n Upon entry  to the state, th...
Introduction to States <ul><ul><li>A state can be active or inactive, once the object enters the state due to a transition...
State Transition <ul><li>A transition from one state to another takes place instantaneously in response to some external e...
State Transition <ul><li>A transition is fired when the following conditions are satisfied: </li></ul><ul><ul><li>The enti...
Self-Transition Al-Tamimi 2011 ©
Composite State Al-Tamimi 2011 ©
Composite State Al-Tamimi 2011 ©
Concurrent Composite State Al-Tamimi 2011 © Initial pseudo- state  May finish at different times
Submachine State Al-Tamimi 2011 © Name of State : Name of Submachine
Entry Point Al-Tamimi 2011 ©
Entry Point Al-Tamimi 2011 ©
Exit Point Al-Tamimi 2011 ©
Choice Pseudo-State Dynamic Conditional Branch Al-Tamimi 2011 ©
Choice Pseudo-State Dynamic Conditional Branch Al-Tamimi 2011 ©
Junction Pseudo-State Static Conditional Branch Al-Tamimi 2011 ©
Junction Pseudo-State Al-Tamimi 2011 ©
Receiving Signal Al-Tamimi 2011 ©
Sending Signal Al-Tamimi 2011 ©
Terminate Pseudo-State Al-Tamimi 2011 ©
History States <ul><li>A history state is used to remember the previous state of a state machine when it was interrupted. ...
Shallow History State Al-Tamimi 2011 ©
Shallow History State Al-Tamimi 2011 © When the activities associated with that state are finished, the system puts the Or...
Deep History State Al-Tamimi 2011 © In this case, that execution should resume with the object in the  Waiting for Back Or...
Fork and Join Al-Tamimi 2011 ©
State Diagram UML Notations Al-Tamimi 2011 © Initial state Final state State Shallow History state Deep History state Conc...
State Diagram UML Notations Al-Tamimi 2011 © Exit Point Entry Point Choice Join and Fork Junction state Transition
Resources <ul><li>Chapter 4, Object-Oriented Technology: From diagram to code with Visual Paradigm for UML </li></ul><ul><...
Upcoming SlideShare
Loading in …5
×

Lecture08

1,347 views
1,209 views

Published on

Statechart Diagrams

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,347
On SlideShare
0
From Embeds
0
Number of Embeds
23
Actions
Shares
0
Downloads
112
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Lecture08

  1. 1. Object Oriented Software Modeling and Design CE 350 Abdel-Karim Al-Tamimi, Ph.D. [email_address] http://faculty.yu.edu.jo/altamimi Al-Tamimi 2011 ©
  2. 2. Overview <ul><li>State Machine Diagram </li></ul>Al-Tamimi 2011 ©
  3. 3. State Machine Diagram <ul><li>The behavior of an entity is not only a direct consequence of its inputs, but it also depends on its preceding state </li></ul><ul><li>The past history of an entity can best be modeled by a finite state chart diagram traditionally named “automata” </li></ul><ul><li>Statechart diagrams (or sometimes referred to as state diagrams ) show the different states of an entity </li></ul><ul><li>Statechart diagrams can also show how an entity responds to various events by changing from one state to another (what states should our system be)   </li></ul>Al-Tamimi 2011 ©
  4. 4. What is a State? <ul><li>According to Rumbaugh et al. “ A state is an abstraction of the attribute values and links of an object. Sets of values are grouped together into a state according to properties that affect the gross behavior of the object ” </li></ul><ul><li>For example, consider you have $100,000 in a bank account. The behavior of the withdraw function would be: </li></ul><ul><ul><li>balance := balance – withdrawAmount; provided that the balance after the withdrawal is not less than $0; </li></ul></ul><ul><ul><li>However, if the account balance becomes negative after a withdrawal, the behavior of the withdraw function would be quite different </li></ul></ul>Al-Tamimi 2011 ©
  5. 5. State Characteristics <ul><li>There are several characteristics of states: </li></ul><ul><ul><li>A state occupies an interval of time </li></ul></ul><ul><ul><li>A state is often associated with an abstraction of attribute values of an entity satisfying some condition(s) </li></ul></ul><ul><ul><li>An entity changes its state not only as a direct consequence of the current input, but it is also dependent on some past history of its inputs </li></ul></ul><ul><li>State Machine diagram is used in the design phase of the product </li></ul>Al-Tamimi 2011 ©
  6. 6. State Diagrams Al-Tamimi 2011 ©
  7. 7. Example Al-Tamimi 2011 ©
  8. 8. Example Al-Tamimi 2011 ©
  9. 9. Composite State Al-Tamimi 2011 ©
  10. 10. State UML Notations Al-Tamimi 2011 © State Name Internal Activities Internal Transitions
  11. 11. State Conditions Al-Tamimi 2011 © Action or activity Description entry/ action 1; …; action n Upon entry to the state, the specified actions are performed. exit/ action 1; …; action n Upon exit from the state, the specified actions are performed. do/ activity The specified activity is performed continuously while in this state . event-name(parameters) [guard-condition] / action 1 ; …; action n An internal transition is fired when the specified event occurs and the specified guard condition is true . The specified actions are performed when the transition is fired.
  12. 12. Introduction to States <ul><ul><li>A state can be active or inactive, once the object enters the state due to a transition the state becomes active, and turned to inactive when it leaves it </li></ul></ul><ul><ul><li>There are three types of states: </li></ul></ul><ul><ul><ul><li>Simple states </li></ul></ul></ul><ul><ul><ul><ul><li>Has no sub-states </li></ul></ul></ul></ul><ul><ul><ul><li>Composite states </li></ul></ul></ul><ul><ul><ul><ul><li>Has one or more regions (containers) of sub-states, if it has two or more regions it is called orthogonal </li></ul></ul></ul></ul><ul><ul><ul><li>Submachine states </li></ul></ul></ul><ul><ul><ul><ul><li>Can be reused in other state machine (similar in context to composite state) </li></ul></ul></ul></ul><ul><ul><ul><ul><li>The way UML uses to encapsulate states for reuse </li></ul></ul></ul></ul>Al-Tamimi 2011 ©
  13. 13. State Transition <ul><li>A transition from one state to another takes place instantaneously in response to some external events or internal stimuli </li></ul>Al-Tamimi 2011 © (Event/Trigger) [guard condition]/(Action/Effect)
  14. 14. State Transition <ul><li>A transition is fired when the following conditions are satisfied: </li></ul><ul><ul><li>The entity is in the state of the source state. </li></ul></ul><ul><ul><li>An event specified in the label occurs. </li></ul></ul><ul><ul><li>The guard condition specified in the label is evaluated to be true. </li></ul></ul><ul><li>When a transition is fired, the actions associated with it are executed </li></ul>Al-Tamimi 2011 ©
  15. 15. Self-Transition Al-Tamimi 2011 ©
  16. 16. Composite State Al-Tamimi 2011 ©
  17. 17. Composite State Al-Tamimi 2011 ©
  18. 18. Concurrent Composite State Al-Tamimi 2011 © Initial pseudo- state May finish at different times
  19. 19. Submachine State Al-Tamimi 2011 © Name of State : Name of Submachine
  20. 20. Entry Point Al-Tamimi 2011 ©
  21. 21. Entry Point Al-Tamimi 2011 ©
  22. 22. Exit Point Al-Tamimi 2011 ©
  23. 23. Choice Pseudo-State Dynamic Conditional Branch Al-Tamimi 2011 ©
  24. 24. Choice Pseudo-State Dynamic Conditional Branch Al-Tamimi 2011 ©
  25. 25. Junction Pseudo-State Static Conditional Branch Al-Tamimi 2011 ©
  26. 26. Junction Pseudo-State Al-Tamimi 2011 ©
  27. 27. Receiving Signal Al-Tamimi 2011 ©
  28. 28. Sending Signal Al-Tamimi 2011 ©
  29. 29. Terminate Pseudo-State Al-Tamimi 2011 ©
  30. 30. History States <ul><li>A history state is used to remember the previous state of a state machine when it was interrupted. </li></ul><ul><ul><li>Deep history state </li></ul></ul><ul><ul><li>Shallow history state </li></ul></ul><ul><li>A shallow history &quot;remembers&quot; only the outermost nested state that the given object was in before it left the enclosing composite state. </li></ul><ul><ul><li>You can use shallow history, then, to allow an event to interrupt an activity and then let the object pick up where it left off once it's handled that event </li></ul></ul><ul><li>A deep history &quot;remembers&quot; the innermost nested state at any depth within a composite state </li></ul>Al-Tamimi 2011 ©
  31. 31. Shallow History State Al-Tamimi 2011 ©
  32. 32. Shallow History State Al-Tamimi 2011 © When the activities associated with that state are finished, the system puts the Order back into the Retrieving Books state and the substate in which the Order resided when activity was interrupted, and the Order resumes performing the interrupted activity. (in this case Accumulating from Inventory) When a query event comes in while an Order object is in the Retrieving Books state, the system puts the current activity hold and puts the object into the Checking Status state.
  33. 33. Deep History State Al-Tamimi 2011 © In this case, that execution should resume with the object in the Waiting for Back Order substate.
  34. 34. Fork and Join Al-Tamimi 2011 ©
  35. 35. State Diagram UML Notations Al-Tamimi 2011 © Initial state Final state State Shallow History state Deep History state Concurrent composite state Transition
  36. 36. State Diagram UML Notations Al-Tamimi 2011 © Exit Point Entry Point Choice Join and Fork Junction state Transition
  37. 37. Resources <ul><li>Chapter 4, Object-Oriented Technology: From diagram to code with Visual Paradigm for UML </li></ul><ul><li>UML 2 Certification Guide </li></ul><ul><li>UML-2 in a nutshell, chapter 8 </li></ul><ul><li>http://www.sparxsystems.com.au/resources/uml2_tutorial/uml2_statediagram.html </li></ul>Al-Tamimi 2011 ©

×