TensorLearn
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).

python
class 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).

Mark as Completed

TensorLearn - AI Engineering for Professionals