Summary
In this chapter, we have seen how to use two other creational design patterns: the prototype and the singleton.
A prototype is used to create exact copies of objects. As seen in the implementation example we discussed, using a prototype in Python is natural and based on built-in features, so it is not something even mentioned. The singleton pattern can be implemented by making the singleton
class use a metaclass, its type, having previously defined said metaclass. As required, the metaclass's __call__()
method holds the code that ensures that only one instance of the class can be created.
Overall, these two design patterns help us implement the use cases that other creational patterns do not support; in effect, we have grown our design pattern toolbox to cover more use cases.
The next chapter is about the adapter pattern, a structural design pattern that can be used to make two incompatible software interfaces compatible.