Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 200692.3913 R. McFadyen1 Statechart Diagram A Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart Diagram.

Similar presentations


Presentation on theme: "March 200692.3913 R. McFadyen1 Statechart Diagram A Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart Diagram."— Presentation transcript:

1 March 200692.3913 R. McFadyen1 Statechart Diagram A 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 Reference: Ch 12 UML

2 March 200692.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 between two states indicating that an object in the first state will perform certain actions and enter the second state when a specified event occurs and specified conditions are satisfied

3 March 200692.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 200692.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 200692.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 200692.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 200692.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 200692.3913 R. McFadyen8 active Four States: active overdrawn closed deleted overdrawn deletedclosed Bank Account Example We’ll develop the example by considering each state, and the transitions that can occur when an account is in that state.

9 March 200692.3913 R. McFadyen9 active trx [pos] overdrawn trx [neg]/warn() closed close An account begins by being Active. Once in the Active state, the account can remain active, become overdrawn, or be closed. {trx stands for “transaction” which represents a deposit or withdrawal} Bank Account Example

10 March 200692.3913 R. McFadyen10 activeoverdrawn trx[pos] trx [neg]/warn() close /warn() From the Overdrawn state, an account can remain overdrawn, or move to the active state Bank Account Example [pos] is a guard that stands for “the account balance is positive” [neg] …

11 March 200692.3913 R. McFadyen11 deleted delete closed From the Closed state, an account can move to the Deleted state; it can also be made active again. Deleted is considered the final state for an account reopen active Bank Account Example

12 March 200692.3913 R. McFadyen12 active trx [pos] overdrawn trx [neg]/warn() deleted delete closed close trx [pos] trx [neg]/warn() close /warn() reopen All together: Bank Account Example


Download ppt "March 200692.3913 R. McFadyen1 Statechart Diagram A Statechart Diagram describes states for an object how/why an objects’ state changes A Statechart Diagram."

Similar presentations


Ads by Google