Presentation is loading. Please wait.

Presentation is loading. Please wait.

2007ACS-3913 R. McFadyen1 UML Statechart Diagram A UML Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart.

Similar presentations


Presentation on theme: "2007ACS-3913 R. McFadyen1 UML Statechart Diagram A UML Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart."— Presentation transcript:

1 2007ACS-3913 R. McFadyen1 UML Statechart Diagram A UML Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart Diagram is a State Machine A State Diagram models an object’s decision about what it does when it receives a message

2 2007ACS-3913 R. McFadyen2 States, Events, Transitions State - a condition or situation during the life of an object during which it satisfies some condition, performs some activity, or waits for some event. Event - a noteworthy occurrence An event can trigger a state transition Transition – a relationship is a movement between states in response to some event.

3 2007ACS-3913 R. McFadyen3 State Machine State Machine - a specification of the sequences of states that an object goes through in response to events during its life A State Machine is a graph of states and transitions that describes the response of an instance of a classifier to the receipt of events State Machines may be attached to classes, use cases,...

4 2007ACS-3913 R. McFadyen4 State Diagram - General Form state1state2 event [guard] /action initial state We choose to represent events that suit us - enabling a diagram to represent the level of detail we need final state

5 2007ACS-3913 R. McFadyen5 red States: red silver gold silver gold Bank Account Example – based on dofactory.com example Events: deposits, withdrawals, and interest payments We need to detail the business rules that govern the processing in each state when deposits, withdrawals, and interest payments are made. Using business rules we can draw the transitions: event, guard, action

6 2007ACS-3913 R. McFadyen6 silverred gold An account begins by being Silver. In the Silver state: If there is a withdrawal and the balance becomes less than a lower limit, then the account goes into the Red state. If there is a deposit and the balance gets larger than the upper limit, then the account goes into the Gold state. When interest is paid and the balance gets larger than the upper limit, then the account goes into the Gold state. Bank Account Example Example – Silver State fill in the transitions

7 2007ACS-3913 R. McFadyen7 silverred gold Consider an account in the Red state. Withdrawals are not permitted and if attempted a service charge is applied. If there is a deposit and the balance gets larger than the upper limit, then the account goes into the Silver state. No interest is paid. Bank Account Example Example – Red State fill in the transitions

8 2007ACS-3913 R. McFadyen8 silverred gold Consider an account in the Gold state. If there is a withdrawal and if the balance gets smaller than a lower limit but not less than 0, then the account goes into the Silver state. If there is a withdrawal and if the balance gets less than a 0, then the account goes into the Red state. Interest is paid, and if the balance gets larger … Bank Account Example – Gold State fill in the transitions

9 2007ACS-3913 R. McFadyen9 silver red gold Bank Account Example fill in the transitions for the complete diagram

10 2007ACS-3913 R. McFadyen10 Gumball Example from Head First Design Patterns See pages 385+ Examples from Schaum’s UML Outline See pages 260-264


Download ppt "2007ACS-3913 R. McFadyen1 UML Statechart Diagram A UML Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart."

Similar presentations


Ads by Google