December 2018
Intermediate to advanced
512 pages
8h 51m
English
This chapter covers the state pattern.
Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
Suppose that you are dealing with a large-scale application where the codebase is rapidly growing. As a result, the situation becomes complex and you may need to introduce lots of if-else blocks/switch statements to guard the various conditions. The state pattern fits in such a context. It allows your objects to behave differently based on the current state, and you can define state-specific behaviors with different ...