Summary
In this chapter, we took a detailed tour of object-oriented design patterns, and found out new and different ways to implement 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 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access