Design Patterns
The Observer Pattern and Event-Driven Design
Decouple publishers from subscribers by letting objects register interest in events without the producer knowing who is listening.
The Observer pattern defines a one-to-many dependency: when a subject's state changes, all registered observers are notified automatically. This decouples the subject from its dependents — the subject does not know how many observers exist or what they do. Modern event buses, domain event dispatchers, and reactive streams all implement this idea at different scales.
Continue reading
- →
Dependency Injection and IoC Containers
Invert control of dependency creation to keep classes decoupled from their collaborators and trivially testable.
- →
The Strategy Pattern: Encapsulating Algorithms
Define a family of algorithms, encapsulate each one, and make them interchangeable — open for extension, closed for modification.
- →
The Factory Pattern: Centralising Object Creation
Delegate the responsibility of creating complex objects to a dedicated factory, keeping construction logic out of the domain and callers.