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

Architecting Your Project with a Finite-State Machine

Architecting Your Project with a Finite-State Machine

Patrick Seda

February 24, 2017
Tweet

More Decks by Patrick Seda

Other Decks in Programming

Transcript

  1. Patrick Seda @pxtrick - CTO of Colligo Vox - Mobile/Technology

    Solutions Consulting - 25+ Years as a Software Professional - Apps: Enterprise to Children’s games
  2. -  Abstract machine -  Can be in exactly one of

    a finite number of states at a time -  State changes via input events -  Transitions -  Module finite-state machine
  3. configuring // JSON example ... var config = { states:

    { ‘DoorClosed’: { events: { ‘open’: { toState: ‘DoorOpen’} } }, ‘DoorOpen’: { events: { ‘close’: { toState: ‘DoorClosed’} } } }, startState: ‘DoorClosed’ };
  4. Armed Stay Armed Away Armed Max Exit Delay? Entry Delay?

    Motion? No Yes Yes Yes Yes No No Yes Yes Armed Instant No No No a honeywell system
  5. state pattern •  Separates interface from implementation •  Enables interchangeable

    behavior •  Perfect for a state machine! Context State State A State B handle() handle() handle()