This document discusses state machines, Petri nets, and the Symfony workflow component. It describes finite state machines as a mathematical model for modeling computation and transitions between states. Petri nets are introduced as a generalization of state machines using a bipartite graph structure. The Symfony workflow component provides an implementation of workflows and state machines using concepts from Petri nets. Examples of configuring and using workflows in Symfony are presented, along with code smells that may indicate an opportunity to introduce a state machine pattern.
12. gytis@ .lt
moore oven
State: OFF
output: no heat
State Heating
output: heat
State Idling
output: no
heat
BAKE
pressed
OFF
pressed
too hot
too cold
OFF
pressed
27. gytis@ .lt
workflow net
● subset of petri net.
● a single input (source) place with no
previous transitions
● output place (sink) with no following
transitions.
38. gytis@ .lt
state machine validation
A transition in StateMachine can only have one output.
A transition in StateMachine can only have one input.
A transition from a place/state must have an unique name.
51. gytis@ .lt
what to look for?
● records that are only valid for a certain period of time.
e.g. subscription expiry date
● or records with NULLABLE datetime fields paid_at, deleted_at, published_at, etc.