Strategy, Abstract Factory, and Singleton Design Patterns
This chapter explores object creation using a few classic, simple, and yet powerful design patterns from the Gang of Four (GoF). These patterns allow developers to encapsulate and reuse behaviors, centralize object creation, add flexibility to our designs, or control object lifetime. Moreover, you will most likely use some of them directly or indirectly in all the software you build.
The GoF is the name given to Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, authors of Design Patterns: Elements of Reusable Object-Oriented Software (1994). In that book, they introduced 23 design patterns, some of which we revisit in this book.
Why are they that important? Because they are the building blocks of robust object composition and help create flexibility and reliability. I grouped these patterns in this chapter because they are the building blocks of Chapter 8, Dependency Injection, where we will...