Example design patterns implemented in python, some written while reading Head First Design Patterns and others added later.
Currently implemented:
- Interface
- Command
- Decorator
- Factory
- Abstract Factory
- Iterator
- Remote Proxy
- Singleton
- Observer
Example scripts exist for some of the patterns which show it working in an unrealistic real world example.
To run the examples for each of the patterns do:
python3 -m example-design-patterns.<name_of_pattern>
# E.g. run the interface example
python3 -m example-design-patterns.interface
It is recommended that you first install the package requirements into a virtualenv file
# Create and activate the venv
python3 -m virtualenv venv
. venv/bin/activate
# Install required packages into venv
python3 -m pip install -r requirements.txt
The project uses pytest to run the tests, you can therefore run them with:
python3 -m pytest