Structural design patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient.
This repository contains implementations of the following structural patterns in Python:
The Adapter pattern allows incompatible interfaces to work together by converting the interface of one class into another interface the client expects.
The Composite pattern lets you compose objects into tree structures to represent part-whole hierarchies. It allows clients to treat individual objects and compositions uniformly.
The Proxy pattern provides a surrogate or placeholder for another object, controlling access to it.
The Decorator pattern lets you attach additional responsibilities to objects dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
- test_component.py
- test_concrete_component.py
- test_concrete_decorator_a.py
- test_concrete_decorator_b.py
- test_decorator.py
The Facade pattern provides a simplified interface to a complex subsystem.
The Bridge pattern decouples an abstraction from its implementation so the two can vary independently.
- abstraction.py
- extended_abstraction.py
- implementor.py
- concrete_implementor_a.py
- concrete_implementor_b.py
- test_abstraction.py
- test_extended_abstraction.py
- test_implementor.py
- test_concrete_implementor_a.py
- test_concrete_implementor_b.py
This repository demonstrates the use of structural design patterns in Python with clear examples and separated test files. Each pattern is structured in its own folder with dedicated test coverage to ensure correct behavior and maintainability.