| State Design Pattern | |
|---|---|
| Desc: |
State Pattern is a design pattern for implementing state machines
without creating a web of functions and switc/cases to change from
one state to another, also without the huge state matrix that always
give us nightmares.
The approach is simple and you should read it from who really knows what it is by reading this PDF. My simple explanation is: each state have a common method for running and changing states. The state controller should only call those methods and ask the states themselves to change it's current state instead of changing itself. This way, you should only code inside states and nothing on state controller or outside of it. It is then, much easier to add new states, change the behaviour of the machine and use the same code for different purposes.
|
| Source: |
The source now is merely my header file, which can be used for any
purpose. But I haven't used it for more than one purpose, so it's
not as generic as I would expect so, please, change it to your own
purposes.
If you feel you could let this file more generic, please contact me, I'd love to hear from you.
|
| Rengolin | This page was created using Vim |