Chapter 11
Common Design Patterns
In the previous chapter, we introduced the concept of a design pattern, and covered the iterator pattern, a pattern so useful and common that it has been abstracted into the core of the programming language itself. In this chapter, we’ll be reviewing other common patterns and how they are implemented in Python. As with iteration, Python often provides an alternative syntax to make working with such problems simpler. We will focus on the Python implementations for these patterns, especially when the pattern is a first-class part of the Python language.
In this chapter, we’ll look at the following:
-
The Decorator pattern
-
The Observer pattern
-
The Strategy pattern
-
The Command pattern
-
The State pattern
-
The Singleton pattern
Consistent with the practice in the book Design Patterns: Elements...