Back to Course
Python Essentials: The Engineering Approach
Module 20 of 20
20. Design Patterns
1. Singleton
A class that has only ONE instance (e.g., Database Connection).
pythonclass Database: _instance = None def __new__(cls): if cls._instance is None: cls._instance = super().__new__(cls) return cls._instance
2. Factory
A function that creates objects without exposing the logic to the client.
3. Observer
A subscription mechanism (EventListener).