From: Alexey Verkhovsky Date: 2004-04-08T06:37:22+09:00 Subject: Re: building UIs with statecharts Phil Tomson wrote: > Do others use state-machines for [driving the logic of rich user interfaces]? Ain't know about Ruby [yet], but when writing thick GUIs in Java I use state machines for anything bigger than a simple popup dialog. Resulting code is somewhat more verbose, but comes out rather stable due to very clean separation of buttons and logic. In really complex situations, write a separate class for each state. Transition from state to state is then a factory method in the originating state, which creates an instance of the destination state, and passes control there. Main loop (translated to Ruby) is something like: state = InitialState.new state = state.getNextState until state.final? Best regards, Alexey Verkhovsky