This repository demonstrates the implementation of various design patterns in Python. Each pattern is implemented in its own directory with clear examples and explanations to help you understand and apply these patterns in real-world scenarios.
Design-Patterns/
├── Observer-Pattern/ # Implementation of the Observer Pattern
│ ├── client.py # Entry point for the Observer Pattern example
│ ├── README.md # Documentation for the Observer Pattern
│ ├── legacy/ # Legacy implementation for comparison
│ └── observer/ # Core implementation of the Observer Pattern
├── Strategy-Pattern/ # Implementation of the Strategy Pattern
│ ├── client.py # Entry point for the Strategy Pattern example
│ ├── README.md # Documentation for the Strategy Pattern
│ ├── legacy/ # Legacy implementation for comparison
│ └── strategy/ # Core implementation of the Strategy Pattern
├── LICENSE # License for the repository
└── CODE_OF_CONDUCT.md # Code of Conduct for contributors
The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. This is demonstrated using a weather station example.
- Directory:
Observer-Pattern/
- Key Features:
- Decoupled design using subjects and observers.
- Real-world example of a weather station.
- Legacy implementation for comparison.
The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. This pattern lets the algorithm vary independently from clients that use it.
- Directory:
Strategy-Pattern/
- Key Features:
- Encapsulation of algorithms.
- Real-world example of a processing strategy.
- Legacy implementation for comparison.
- Clone the repository:
git clone https://github.com/your-username/design-patterns.git
- Navigate to the desired pattern directory (e.g.,
Observer-Pattern
orStrategy-Pattern
). - Follow the instructions in the respective
README.md
file to run the examples.
- Python 3.7+
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or additional patterns.
This project is licensed under the MIT License. See the LICENSE file for details.
Please adhere to the Code of Conduct when contributing to this project.