The Observer Pattern

Imagine a typical Australian suburban family home with the average 1. 9 children and 0.2 of a pet (at least it is cheap to feed).

Typical evening scene pre-observer implementation!!!
Dad - “Have you done your homework?”
Child 0.9 - “Uh no whatever!”

0.1667 Seconds later.
Dad - “Have you done your homework?”
Child 0.9 - “Uh no whatever!”

0.1667 Seconds later.
Dad - “Have you done your homework?”
Child 0.9 - “Uh no whatever!”

Revisited evening scene post-observer implementation!!!

Child 0.9 has decided to notify the world by shouting when homework has been completed and doesn’t give a monkeys about who is listening.

Dad has heard Child 0.9s decision and sits there listening out.

Now what I should be telling you is a happy ending story. Where Child 0.9 has completed the homework in a timely and appropriate manner and shouts out. Dad listens and smiles contented knowing that all about the world is good. The next door neighbour is banging on the wall, complaining about the shouting from Child 0.9 about home work being done.

In reality, Dad either ends up going to have his hearing checked as he never seems to hear the shout or sits in his chair fuming and cussing about the state of the world and the youth of today.

2 Likes

lol - nice write up of your understanding there Jon, lol… :smiley: :smiley:

I would suggest you’ve written a perfect example, albeit perhaps the implementation isn’t quite right :wink:

1 Like

Privacy & Terms