A project is a good candidate to use a state machine if:
-
The application or part of its structure can be represented as states.
-
You want to split complex logic into smaller manageable tasks.
-
The application is already suffering concurrency issues with i.e.
something happening asynchronously.
You are already trying to implement a state machine if:
-
Using boolean flags or enums to model situations.
-
Having variables which only have meaning for some part of your
application lifecycle.
-
Looping through if/else structure and checking if a particular flag or
enum is set and then making further exceptions about what to do when certain
combinations of your flags and enums exist or don’t exist together.