Chapter 5. State Patterns

Science is a collection of successful recipes.

Paul Valéry

In the previous chapter, you learned how to implement hierarchical state machines (HSMs) in C and C++ with the generic hierarchical event processor called QEP. In fact, QEP enabled a rather mechanical one-to-one mapping between state models and the code. With just a bit of practice, you will forget that you are laboriously translating state models into code; rather, you will directly build state machines in C or C++.

At this point, you will no longer struggle with 15 levels of if–else statements and gazillions of flags. You will start thinking at a higher level of abstraction about the best ways to partition behavior into states, about the structure of your state ...

Get Practical UML Statecharts in C/C++, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.