Skip to content

Convention Guide

Fahmi Akbar Wildana edited this page Jun 10, 2019 · 13 revisions

When designing a State Machine, you need to know the purpose. Each State Machine has a slightly different convention.

State Machine for...

Manage users workflow

  • When the element name of the State Machine similar to each other:
    • Rename the state as past or continuous tense when it has the same name as the event. However, try to avoid this because not all world languages have a past or continuous tense verb
  • For the event name, the name must answer this question:
    1. What is the event? (Answer: pay)
    2. How to trigger it? (Answer: by clicking the button or hit the enter key)
  • Use Protocol Transition when you want to explain the lifecycle of some states
  • Use guards as a weight when designing UI that adapts to data. In other word, mix it with weighted graphs.

Manage system processes

  • Always think about how the system can recover from failure
  • Usually, they use self (loop) and backward transition to recover from failure
  • Use Protocol Transition when you want explain lifecycle of some processes
  • Use guards when you want to make adaptive processes

Creating deterministic A.I

  • for deterministic A.I, use Behaviour Tree (HSFM vs Behaviour Tree) or
  • shape it as an acyclic graph (no self or backward transition)
  • use guards when designing probabilistic A.I (weighted graph)

Manage resources or data

  • utilize State Management library or
  • rely heavily on invoking/spawning services, calling actions, and assigning a context