Chapter 2. The Singleton Design Pattern
In the previous chapter, we explored design patterns and their classifications. As we are aware, design patterns can be classified under three main categories: structural, behavioral, and creational patterns.
In this chapter, we will go through the Singleton design pattern—one of the simplest and well-known Creational design patterns used in application development. This chapter will give you a brief introduction to the Singleton pattern, take you through a real-world example where this pattern can be used, and explain it in detail with the help of Python implementations. You will learn about the Monostate (or Borg) design pattern that is a variant of the Singleton design pattern.
In this chapter, we will cover the following topics in brief:
- An understanding of the Singleton design pattern
- A real-world example of the Singleton pattern
- The Singleton pattern implementation in Python
- The Monostate (Borg) pattern
At the end of the chapter, we...