My favourite design pattern: The Observer
Why Observer is so cool?
Managing complexity in large code base is all about decoupling. Observer is a perfect tool to do that. The Observed
object has no idea about its observers, no dependency injection is required at all, as a result a loose coupling is achieved between two classes of objects where the only common part is the interface they agree upon.
First iteration
It’s a classic design pattern and I’m sure majority (if not all) of engineers know the details behind it, most of us implement it in a slightly different way, depending on the requirements and the code base we are working with though. Here’s my flavour of this design pattern.