Your SlideShare is downloading. ×
0
abcdefg
CxStates
Little Smalltalk Exercise:
A dynamically defined state model
not based on the state pattern
presented by
...
abcdefg
awu060829 2
The Author
● Smalltalker since 1992
● Project OVID at Fides Informatik (1992-1999)
– OVID currently in...
abcdefg
awu060829 3
Motivation
● We needed a user configurable state model
– so, preferably should not be class based
– sh...
abcdefg
awu060829 4
Basic classes (1)
● CxBaseState
– defines a state
● has a name
● has a transitionTable
– contains lega...
abcdefg
awu060829 5
Basic Classes (2)
● CxActionSequence and CxAction
– for execution of methods in the „outer System“
– e...
abcdefg
awu060829 6
Action execution
current
State
new
State
Transition
PreTransition
Actions
PostTransition
Actions
preTr...
abcdefg
awu060829 7
Action
CxAction
A CxAction contains a message
send. CxAction is declared in the
transitionEntry. The m...
abcdefg
awu060829 8
Declaration of actions
● in CxBaseState:
– whenCxPreTransition: aTransitionSymbol send:
aSelector to: ...
abcdefg
awu060829 9
CxTransitionContext
● Is an argument holder for the messages sent to
the „outer system“
– combines rec...
abcdefg
awu060829 10
CxBaseState>>doTransition:
● Executes the defined CxActions
– By delegation to CxTransitionEntry>>doT...
abcdefg
awu060829 11
Demonstration
● Automatic Coffee Machine
– Power switch
– „Make Coffee“ button
– grinding automatic (...
abcdefg
awu060829 12
Coffee States
Switched Off
Switched On
Grinding/
Heating
Heating
Brewing
Init
initializeMachine
switc...
abcdefg
awu060829 13
Extensions
● CxCondition
– allows to inhibit preTransitions by outer system
conditions
– analogous to...
abcdefg
awu060829 14
Thank you for listening
Questions?
Upcoming SlideShare
Loading in...5
×

CxStates

185

Published on

CxStates. ESUG 2006, Prague

Published in: Technology, Economy & Finance
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
185
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "CxStates"

  1. 1. abcdefg CxStates Little Smalltalk Exercise: A dynamically defined state model not based on the state pattern presented by Alfred Wullschleger Swiss National Bank
  2. 2. abcdefg awu060829 2 The Author ● Smalltalker since 1992 ● Project OVID at Fides Informatik (1992-1999) – OVID currently in production more than 11 years ● Project OASE at Swiss National Bank (since 1999 in production) – Financial Statistics from Swiss Banks and Companies – based on Gemstone/S and VisualWorks – ongoing development under full production
  3. 3. abcdefg awu060829 3 Motivation ● We needed a user configurable state model – so, preferably should not be class based – should allow easy communication with the „outer system“ = the system components which are not part of the state model itself ● Solution: CxStates – ANSI Event Model as implementation pattern
  4. 4. abcdefg awu060829 4 Basic classes (1) ● CxBaseState – defines a state ● has a name ● has a transitionTable – contains legal transitions to other states through transition entries ● CxTransitionEntry – defines a transition by a symbol and the new state ● includes transitionActions
  5. 5. abcdefg awu060829 5 Basic Classes (2) ● CxActionSequence and CxAction – for execution of methods in the „outer System“ – extensible analoguous to the event model ● CxStateEnsemble – Defines a complete state diagram – Defines all legal transition symbols
  6. 6. abcdefg awu060829 6 Action execution current State new State Transition PreTransition Actions PostTransition Actions preTransitionActions in context of current state postTransitionActions in context of new state
  7. 7. abcdefg awu060829 7 Action CxAction A CxAction contains a message send. CxAction is declared in the transitionEntry. The message receiver is typically inserted during the transition
  8. 8. abcdefg awu060829 8 Declaration of actions ● in CxBaseState: – whenCxPreTransition: aTransitionSymbol send: aSelector to: aReceiver ● adds a CxAction to the PreTransitionActionSequence ● aReceiver can be nil: the receiver can be dynamically set when the transition is executed ● polymorphically delegated to CxTransitionEntry – whenCxPostTransition: aTransitionSymbol send: aSelector to: aReceiver ● the same in context of the new state
  9. 9. abcdefg awu060829 9 CxTransitionContext ● Is an argument holder for the messages sent to the „outer system“ – combines receiver and arguments for the declared action – includes currentState (either the pre- or the postTransition state!) ● CxBaseState>>doTransition: aCxTransitionContext – Basic method for the execution of the transition
  10. 10. abcdefg awu060829 10 CxBaseState>>doTransition: ● Executes the defined CxActions – By delegation to CxTransitionEntry>>doTransition: , and finally to CxAction>>doTransition: ● Returns – nil, when the transition is illegal, state unchanged – false, when the transition is inhibited, state unchanged – the new state, in all other cases ● Inhibit by a special CxAction: CxCondition – Must returns true or false
  11. 11. abcdefg awu060829 11 Demonstration ● Automatic Coffee Machine – Power switch – „Make Coffee“ button – grinding automatic (timer) – Heating (temperature sensor, not simulated) – brewing automatic (timer) – „Stopp brewing“ button – Water supply not simulated
  12. 12. abcdefg awu060829 12 Coffee States Switched Off Switched On Grinding/ Heating Heating Brewing Init initializeMachine switchPowerOn pressButtonForCoffee stopGrinding startBrewing cupFilled cancelBrewing
  13. 13. abcdefg awu060829 13 Extensions ● CxCondition – allows to inhibit preTransitions by outer system conditions – analogous to CxActions but must return a boolean ● CxPostTransitionEntry – technical class for post states which do not contain transitionEntries for the corresponding transition symbol – PostTransitionEntries must be defined in the post state!
  14. 14. abcdefg awu060829 14 Thank you for listening Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×