Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 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: "March 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 March 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 March 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 March 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 March 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 March 2007ACS-3913 R. McFadyen5 Library Book Example Now consider a class Book. Suppose there may be several copies of the book. Here, we’ll model the states Borrowable, and Not borrowable. Not borrowableBorrowable returned borrowed[last copy] returned borrowed[not last copy]

6 March 2007ACS-3913 R. McFadyen6 Library Book Example Not borrowableBorrowable returned borrowed[last copy] returned borrowed[not last copy] Note: when a Book receives the returned event, the next state depends only on the current state when a Book receives the borrowed event, the next state is determined by the guard

7 March 2007ACS-3913 R. McFadyen7 Selling Seats Example availablefull Consider a situation where tickets are being sold for a voyage. Tickets can be sold as long as there are seats available. At some point, all seats could have been sold and the voyage is full. Eventually, sales are closed and no more seats can be sold. We’ll consider states full and available for a voyage. Seat sold [not last one] Seat sold [last one] Sales closed

8 March 2007ACS-3913 R. McFadyen8 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

9 March 2007ACS-3913 R. McFadyen9 silver red 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

10 March 2007ACS-3913 R. McFadyen10 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

11 March 2007ACS-3913 R. McFadyen11 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

12 March 2007ACS-3913 R. McFadyen12 silver red gold Bank Account Example


Download ppt "March 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