From: Robert Klemme Date: 2003-05-14T00:13:33+09:00 Subject: Re: State Pattern Implementation "Simon Strandgaard" <0bz63fz3m1qt3001@sneakemail.com> schrieb im Newsbeitrag news:pan.2003.05.13.11.22.58.618215@sneakemail.com... > > My main idea was to replace the state instance by > > a redefinition of instance methods. > > Interesting thought. So instead of having a state variable you redefine > some state-transition-methods. Clever :-) > > Am I understanding you correct ? Not completely. I don't necessarily redefine the state transition methods but these methods redefine other methods that are supposed to change their behavior in different states. Of course, state transition methods could be redefined as well, but I don't know how messy this will become... > > Pro is, you safe an instance and a redirection; > > on the con side is increased code size for the class since > > you have to include code for all states. > > Because you don't have an explicit state variable, the state becomes > implicit. Thus its hard to tell the current state.. > Just a thought :-) The main problem with this is, that you can't store the current state as Mauricio pointed out. > > I'm curios to know whether anybody did this before. I might be missing > > some grave disadvantage. > > Kind of.. not tried the same. I have done some state machines from time to > time. Most of us did, I guess. robert