State machines are a superb formalism for specifying and implementing event-driven systems. The UML statecharts represent the current state of the art in state machine theory and notation. This paper covers the essence of statecharts, describes a particularly small and highly maintainable implementation of statecharts in C and C++, and offers some useful heuristics for effective statechart designs. You will learn that statecharts are a powerful way of design that you can use even without the assistance of sophisticated tools.