4. Observer Pattern
Observer Pattern Ideally, every system should involve a set of loosely-coupled entities. That’s loosely-coupled, not totally-unaware of each other. Objects need to be made aware of each other and be able to respond to each other’s actions.
Today’s Example
Finally, a pay rise An Employee gets a pay raise Payroll needs to be updated Tax man gets 50% of it How do we get these objects informed?
Keep a copy of the related objects
Why should the Employee do all the work? “ Separate out the change from the things that stay the same.” We need a list of objects that want to know about the changes to the Employee. The “observers”
Observers in Action
Observers in Action
Observers in Action

Design patterns 4 - observer pattern