Level: Intermediate (some prior knowledge necessary)
Length: Shorty (30 minutes)
Description:
Determining the current state of an entity can be difficult. For many, determining state is always implicit — typically taking the form of booleans and timestamps littered throughout database columns and the codebase. The ever growing list of rules used to determine state are rarely documented and even less often tested. What can we do?
Simple state machines, allow us to make our state explicit and provide clear instructions on when and how that state should change, as well as what side effects should occur. By making our state explicit, we can eliminate edge cases, write less code, and confidently test our implementations. The great news is that you don’t need to make large changes to benefit from this simple pattern!
During this talk, participants will learn:
- The event-state-action paradigm
- How to create a state chart / diagram
- How to implement a simple state machine
- How to refactor to, and test, a simple state machine from existing code