Behavioral design patterns focus on how objects interact and communicate with each other. They help define clear communication pathways, responsibilities, and execution flows.
This repository contains implementations of the following behavioral patterns in Python:
The Observer pattern defines a one-to-many dependency between objects so that when one object changes state, all dependents are notified automatically.
- test_subject.py
- test_observer.py
- test_concrete_subject.py
- test_concrete_observer_a.py
- test_concrete_observer_b.py
The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable.
The Command pattern turns requests into standalone objects, allowing operations such as queuing, logging, undo, and flexible invocation.
- test_command.py
- test_receiver.py
- test_concrete_command_a.py
- test_concrete_command_b.py
- test_invoker.py
The State pattern lets an object alter its behavior when its internal state changes. The object will appear to change its class.
The Mediator pattern defines an object that encapsulates how a set of objects interact, promoting loose coupling by preventing direct references.
- test_mediator.py
- test_colleague.py
- test_concrete_colleague_a.py
- test_concrete_colleague_b.py
- test_concrete_mediator.py
The Chain of Responsibility pattern allows passing a request along a chain of handlers. Each handler can choose to process the request or pass it onward.
This repository demonstrates the use of behavioral design patterns in Python with clear, separated implementations and comprehensive tests. Each pattern resides in its own folder and includes dedicated test coverage to ensure correctness, maintainability, and ease of understanding.