The state design pattern is really similar to the strategy design pattern that we looked at in the previous chapter.
Basically, the difference between the state design pattern and the strategy design pattern comes from the following two points:
- The strategy design pattern is about how an action is performed. It is usually an algorithm that produces the same results as other algorithms.
- The state design pattern is about what action is performed. Depending on the state, an object could be doing different things.
Implementing the state design pattern also closely resembles the implementation ...