In this chapter, we took a detailed tour of object-oriented design patterns, and found out new and different ways of implementing them in Python. We started with an overview of Design Patterns and their classification into Creational, Structural, and Behavioral patterns.
We went on to see an example of a Strategy design pattern, and saw how to implement this in a Pythonic manner. We then began our formal discussion of patterns in Python.
In Creational patterns, we covered the Singleton, Borg, Prototype, Factory, and Builder patterns. We saw why Borg is usually a better approach than the Singleton in Python due to its ability to keep state across class hierarchies. We saw the interplay between the Builder, Prototype, and Factory patterns, and saw a few examples. Everywhere possible, metaclass discussions were introduced, and pattern implementations were done using metaclasses.
In Structural patterns, our focus was on the Adapter, façade, and Proxy patterns. We saw detailed examples using...