Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the observer pattern?

Observer Pattern
0
Posted

What is the observer pattern?

0

As mentioned in the introduction the observer pattern allows us to implement a one-to-many relationship in a loosely coupled fashion. Loosely coupled means that the objects don’t know much about each other, they know just enough to get the job done. To illustrate the observer pattern imagine you want to subscribe to Time magazine. You go to the Time magazine website, fill out a few forms and now you are subscribed for a time period of your choosing. In this scenario we will say that Time magazine is the subject, and you, along with all other subscribers are the observers. When a new issue of Time magazine comes out you will be notified via the physical receipt of the latest issue. If we cast our minds back to a time before we were subscribers of the magazine we will remember that when a new issue came out we didn’t receive a copy, and we probably weren’t even told about the availability of a new issue. In the preceding example scenario we identified that Time magazine was the subject,

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.