Download presentation
Presentation is loading. Please wait.
Published byDomenic Gilbert Modified over 9 years ago
1
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 1 object states an object state is a condition or situation during the life of an object during which it: satisfies some condition or performs some activity or waits for some event the current state of an object determines how it will behave the current state of an object is determined by: current values of attributes and current links with other objects
2
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 2 an object moves from one state to another by a transition which is either: triggered by an event or the state simply finishes (triggerless transition) statechart diagram is a model of: all the states and object can have the events that cause transitions all possible responses to all use cases Not all messages an object can receive will alter its state, in particular messages that do not cause changes to attributes or links (e.g. “get” and “query”)
3
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 3 events may trigger action by actor or object time end of designated time period after [time expression] change when a condition becomes true when [Boolean expression] signal receipt of an asynchronous communication signal call receipt of call for an operation (synchronous) from self or other object events event-signature [guard-condition] / return-value:= action-expression
4
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 4 event-signature [guard-condition] / return-value:= action-expression event-signature operation (parameter-list) guard-conditionBoolean expression action expressionoperation (paramter-list) an example showing multiple actions... leftMouseDown(location) [validItemSelected] / menuChoice:= pickMenuItem(location); menuChoiceHighlight ( ) three more examples... /assignManager ( ) ; assignStaff ( ) authorization (authorizationCode) [contract signed] / setCampaignActive ( ) paymentReceived ( payment) [paymentDue – payment <= zero] / A[B]/C if told to do A and B is true, then also do C, causing a state change if told to do A and B is false, then don’t do C and state does not change if no guard condition, then state always changes
5
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 5 labels and notation event-signature [guard-condition] / return-value:= action-expression
6
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 6 basic notation
7
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 7 statechart for the class DiscountRate createDiscount- Rate ( )
8
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 8 hospital patient
9
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 9 online order
10
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 10 video store – movie title
11
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 11 online order
12
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 12 alarm system
13
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 13 fax machine
14
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 14 concurrent substates in this example, either transition T1 or T2 can cause the object to leave any of states A1, A2, A3 or B1, B2, B3 and until either T1 or T2 occurs, the object remains in substate 1 and substate 2 A1A2 A3 B1B2 B3 T1T2
15
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 15 when developing state charts... what are the major system events? what objects are affected by these events? (state charts are created) what alternate scenarios exist? (state charts are enhanced) are the state charts consistent with all use cases, collaboration and sequence diagrams? (state charts are corrected if necessary)
16
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 16 when checking statecharts... every event appears as an incoming message for the appropriate object in the right interaction (sequence or collaboration) diagram? corresponds to an operation on the appropriate class? every action appears as an operation in that object’s class? every outgoing message corresponds to an operation in another class?
17
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 17 example: Menu Visible state for a DropDownMenu object Entry action causes the menu to be displayed Event itemSelected() triggers the action highlightItem() Exiting the state triggers hideMenu() While the object remains in the Menu Visible state, the activity causes a sound clip to be played
18
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 18 Synchronized Concurrent Threads. Synchronization bar n Explicitly showing how an event triggering a transition to a state with nested concurrent states causes specific concurrent substates to be entered n Shows that the composite state is not exited until both concurrent nested statecharts are exited
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.