Summary
Altogether, we have covered three patterns that you can build into any future project: the Singleton pattern, which makes sure there is – and only ever will be – one instance of an object that exists, the Command pattern, which provides the utility of separation between the request for an action and that action happening, and finally, the State pattern, which separates our mutually exclusive logic.
At this point, you should understand that Singleton does work in some cases, but it has its drawbacks. The Command pattern can be used for so many different things that you should probably make a version of it as a template library for use in all future projects, and the State pattern has so many layers that it can ruin its own usefulness with depth.
The next chapter will explore some behavioral patterns that solidify the behavior of a class in different ways to improve the expandability of our systems – namely, the type object pattern, which we would posit...