Event-driven programming is widely used in [[graphical user interfaces] because it has been adopted by most commercial widget toolkits as the model for interaction. The design of those toolkits has been criticized for promoting an over-simplified model of event-action, leading programmers to create error prone, difficult to extend and excessively complex application code:
Such an approach is fertile ground for bugs for at least three reasons:
1. It always leads to convoluted conditional logic.
2. Each branching point requires evaluation of a complex expression.
3. Switching between different modes requires modifying many variables, which all can easily lead to inconsistencies.
Instead of a low level action-reaction, Miro Samek proposes a better approach using finite State Machines to control the interaction logic necessary to define the state changes to incoming events. Hierarchical State Machines have also been proposed as a high-level model for reactive programs. The UML language in particular provides a complete specification to represent state machines.
Some alternate implementations: