![]() Most reactive programs start out fairly simple and well structured, but as features are grafted on, more and more flags and variables are introduced to capture the relevant event history. In all but the most trivial reactive systems, the response depends both on the nature of the event and, more importantly, on the history of past events in which the system was involved.įrom the programming perspective, this dependence on context very often leads to deeply nested if-else or switch-case constructs. State Machines Reduce Spaghetti CodeĪs I pointed out in State Machines for Event-Driven Systems, the main challenge in programming reactive (event-driven) systems is to correctly identify the appropriate piece of code to execute in response to a given event. I hope that these simple techniques can become more common, so that we can more often easily see the state-machine structure right from the source code. This article provides an introduction to state machines fundamentals plus practical advice for implementing them in C or C++. ![]() Many embedded systems consist of a collection of state machines at various levels of the electronics or software. ![]() A state machine is any object that behaves different based on its history and current inputs. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |