Chapter 12
Advanced Design Patterns
In this chapter, we will introduce several more design patterns. Once again, we’ll cover the canonical examples as well as any common alternative implementations in Python. We’ll be discussing the following:
-
The Adapter pattern
-
The Facade pattern
-
Lazy initialization and the Flyweight pattern
-
The Abstract Factory pattern
-
The Composite pattern
-
The Template pattern
Consistent with the practice in Design Patterns: Elements of Reusable Object-Oriented Software, we’ll capitalize the pattern names.
We’ll begin with the Adapter pattern. This is often used to provide a needed interface around an object with a design that doesn’t — quite — fit our needs.