Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Application Design 勉強会 #12

Application Design 勉強会 #12

状態マシンとStateパターン

Kazuki Chigita

November 11, 2019
Tweet

More Decks by Kazuki Chigita

Other Decks in Programming

Transcript

  1. 状態遷移図 Locked Unlocked coin/unlock pass/lock 状態 遷移 イベント アクション index

    state event next action 1 Locked coin Unlocked unlock 2 Unlocked pass Locked lock ...
  2. 状態遷移図 Locked Unlocked coin/unlock pass/lock 状態 遷移 イベント アクション index

    state event next action 1 Locked coin Unlocked unlock 2 Unlocked pass Locked lock ... 状態遷移テーブル (STT : State Transition Table)
  3. プログラムでどう表現するか? 3+α. Stateパターン+状態マシンコンパイラを用いる FSMName Turnstile Context TrunstileActions Intial Locked Exception

    FsmError { Locked { coin Unlocked unlock pass Locked alarm } Unloked { coin Unlocked thankyou pass Locked lock } } Auto Generate
  4. プログラムでどう表現するか? 3+α. Stateパターン+状態マシンコンパイラを用いる FSMName Turnstile Context TrunstileActions Intial Locked Exception

    FsmError { Locked { coin Unlocked unlock pass Locked alarm } Unloked { coin Unlocked thankyou pass Locked lock } } Auto Generate
  5. GUIのあるログイン画面の状態と表示画面を制御したい 利用例 Initial init { init { start logginIn displayLoginScreen

    } logginIn { enter checkingPassword checkPassword cancel init clearScreen } checkingPassword { passwordGood loggedIn startUserProcess passwordBad notifyingPasswordBad displayBadPasswordScreen thirdBadPassword screenLocked displayLockScreen } ... }