State machines allow you to describe the high level logic of your program while ignoring low level implementation details. They are especially useful for modeling event-driven systems.
Theory and Concepts
Statecharts
Here is the original paper written by David Harel in 1986. This gave birth to the UML state diagrams we have today. Read the full articleUML State Diagrams
This Wikipedia article explains the basics of Events, States, Guards, and Actions. Read this if you need to get up to speed on basic concepts and terminology. Read the full article
State Diagram Crash Course
This 30 page whitepaper makes a strong argument for using state machines instead of giant if-else statements. It uses the Visual Basic calculator program to illustrate how state machines can simplify your code and eliminate bugs. Read the full articleVideos
UML State Diagrams
Derek Banas teaches you the UML notation in this 13 minute YouTube video. Watch the video
Coding a State Machine by Hand
You probably don't want to do this. Watch the video
Libraries and Tools
pystatemachine 1.2
A clever idea. This package uses Python @decorators to turn any class into a state machine. Read the full article
State Machine Compiler (SMC)
Writing state machine code is dull, repetitive, and error prone. Let the computer do it for you. This tool generates Python code from a high-level description of your state machine. Read the full article
No comments:
Post a Comment