A Kotlin DSL for finite state machines

A Kotlin DSL for finite state machines

A journey through finite state machines and a DSL in Kotlin for implementing your own Finite State Machine.

Corneil du Plessis

June 25, 2020

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

25 slides
  1. Quotable quotes K.I.S.S. – Keep it simple stupid! Graeme Mitchell

    “Everything should be a simple as possible, but no simpler” Albert Einstein
  2. A brief history of state machines • FSM/FSA (Finite state

    machines / automa) • DFA/NFA/NDFA (Non-deterministic state machine / automa) • State tables / charts / maps • Mealy / Moore machines (State + Input) vs (State) • UML state machines • SDL state machines
  3. State Event Next State Action LOCKED COIN UNLOCKED unlock PASS

    alarm UNLOCKED COIN return-coin PASS LOCKED lock Transition table for Turnstile
  4. FSM Patterns • Generate code from State Map - SMC

    Class per State, method per Event OR Huge switch statement • Executable XML – SCXML • Language Builder – Spring Statemachine
  5. FSM Features • States • Transition on Events • Guard

    Expressions • Entry / Exit Actions • Typed Event Parameter • Typed Return value • Automatic transitions • Timeouts • Named State Maps • Push / Pop transitions • Multiplatform • No 3rd party dependencies • Visualisations plugin
  6. An example – Choose a technology • Kotlin/JS in the

    Browser Kotlin Only • Kotlin/JS in the Browser JavaScript calling Kotlin • Kotlin JVM in Spring Boot with WebMVC • Kotlin JVM in Spring Boot with REST / HATEOAS (Sample Angular Client) • Kotlin JVM on Android
  7. Resources • Twitter - @corneil • Slides - https://speakerdeck.com/corneil/kfsm-a-kotlin-dsl-for- finite-state-machines

    • Project Source - https://github.com/open-jumpco/kfsm • Samples - https://github.com/open-jumpco/kfsm-samples • SMC - http://smc.sourceforge.net/ • Spring Statemachine - https://projects.spring.io/spring- statemachine/ Questions?

More Decks by Corneil du Plessis

Other Decks in Programming