← Graph

State Machine

concept 7 connections

Pattern where an object has a finite set of states and a set of permitted transitions between them. Krzywda argues business logic is almost always reducible to state machines: every decision in an aggregate is a transition validated against the current state. He demonstrates implementing a JIRA issue state machine (create / resolve / close / reopen) without any state-machine library or framework, by raising on invalid transitions and either keeping a status field or encoding state into the type system via one class per state.

category
pattern
about
State Machine concept
Central claim: business logic is mostly about state machines; the JIRA issue example is a state machine.
about
State Machine concept
The takeaway is that business logic reduces to state machines.
about
State Machine concept
Recommends state machines as the explicit alternative to boolean-flag state encoding.
recommends
State Machine concept
Argues most business logic is a state machine and should be implemented as such without libraries.
recommends
State Machine concept
Ivan Nemytchenko recommends state machines over boolean flags for any state-dependent behavior.
related_to
State Machine concept
Encodes state into the type system by using one class per state.
related_to
State Machine concept
State machines are the explicit alternative to implicit boolean flag states.

Provenance

Read by
13 extractions