This tutorial shows a graphical demo of the observer pattern. The circle, square and mosaic background are all observers of the button press. Whilst the owner of the button is the subject.
The observer pattern has an object named the ‘subject’ which maintains a list of ‘observers’. The subject will notify all the observers when an event occurs. The observers can then choose how they wish to respond to the event.
In the last tutorial you learned how to code the observer pattern in Visual Studio, where you could see the result in the console window.
In this tutorial you can see a graphical implementation of the observer pattern. Every time the button is pushed, three things happen:
- The mosaic background generates new polygon shapes.
- The circle picks a new greyscale value.
- The square switches back and forth between red and green.
The main thing to note here is that these three somewhat different outcomes respond to the same event (a button press). This is the essence of the observer pattern.

The downside of the observer pattern is that you have no control over the execution order of which observers receive the event first (or last), and you can’t omit select observers from receiving an event. When the button is pressed, all the observers will receive the event.
Fun Blooper

Conclusion
Congratulations on completing this tutorial. You have learned about the strength and weaknesses of the observer pattern, and what you can use it for. Thanks for reading this tutorial!

