title: State machine representation
body: <p>I want to implement the GUI as a state machine. I think there are some benefits and some drawbacks of doing this, but this is not the topic of this questions.</p>
  
  <p>After some reading about this I found several ways of modeling a state machine in C++ and I stuck on 2, but I don't know what method may fit better for GUI modeling.</p>
  
  <ol>
  <li><p>Represent the State Machine as a list of states with following methods:</p>
  
  <ul>
  <li><code>OnEvent(...);</code></li>
  <li><code>OnEnterState(...);</code></li>
  <li><code>OnExitState(...);</code></li>
  </ul>
  
  <p>From <code>StateMachine::OnEvent(...)</code> I forward the event to <code>CurrentState::OnEvent(...)</code> and here the decision to make a transition or not is made. On transition I call <code>CurrentState::OnExitState(...)</code>, <code>NewState::OnEnterState()</code> and <code>CurrentState = NewState;</code></p>
  
  <p>With this approach the state will be tightly coupled with actions, but <code>State</code> might get complicated when from one state I can go to multiple states and I have to take different actions for different transitions.</p></li>
  <li><p>Represent the state machine as list of transitions with following properties:</p>
  
  <ul>
  <li><code>InitialState</code></li>
  <li><code>FinalState</code></li>
  <li><code>OnEvent(...)</code></li>
  <li><code>DoTransition(...)</code></li>
  </ul>
  
  <p>From <code>StateMachine::OnEvent(...)</code> I forward the event to all transitions where <code>InitialState</code> has same value as <code>CurrentState</code> in the state machine. If the transition condition is met the loop is stopped, <code>DoTransition</code> method is called and <code>CurrentState</code> set to <code>Transition::FinalState</code>.</p>
  
  <p>With this approach <code>Transition</code> will be very simple, but the number of transition count might get very high. Also it will become harder to track what actions will be done when one state receives an event. </p></li>
  </ol>
  
  <p>What approach do you think is better for GUI modeling. Do you know other representations that may be better for my problem?</p>