Home

Awesome

Awesome FSM Awesome

<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/DFAexample.svg/500px-DFAexample.svg.png" align="right" width="100">

Useful resources for creating apps that use the finite state machine pattern

Inspired by the awesome list thing.

Préambule 🌭

Finite state machine won't save the world. This pattern address issues where you want to drive a user from a point A to Z following various state. Thus make sure you really need a state machine before using one. But also make sure you won't need one, because most of the time you will. We have four rules that leads this design:

  1. The state machine is defined by a finite number of states
  2. This states are triggered by conditions
  3. Each conditions shapes transition
  4. The machine is in only one state at a time; we call it the current state

Interesting reading about state machine 📖

FSM can be simply compared to somebody with amnesia who is constantly asking: Where am I? What just happened? and…

So what do I do (or where do I go) next?

Robert Drummond

Two other examples where the State pattern is useful include: vending machines that dispense products when a correct combination of coins is entered, and elevator logic which moves riders up or down depending on certain complex rules that attempt to minimize wait and ride times.

dofactory

This man has never heard of video game A.I. programming :)

davedx

There’s nothing to prevent “air jumping” — keep hammering B while she’s in the air, and she will float forever. The simple fix is to add an isJumping_ Boolean field to Heroine that tracks

Robert Nystrom

We Don't Need One Until We Do So, early on you don't feel like your objects' state machine behaviour is complex enough to warrant a "full-blown" state machine (YAGNI and all that jazz), but later on – when it IS complex enough – you feel like you've invested too much time/effort to replace it with something that has equivalent functionality

Alan Skorkin

React thinks of UIs as simple state machines.

Libraries 📚

Examples

TODO 🛠