Implementing Newsletter Subscription using Observer Design Pattern in Java


Observer pattern is used when there is one-to-many relationship between objects such as if one object is modified, its depenedent objects are to be notified automatically. Observer pattern falls under behavioral pattern category.



Say, for example, you and several other readers subscribed to a newsletter. When there is a new newsletter available, you will receive it along with other subscribers. Suppose, if you don’t want to receive the newsletter, you can cancel your subscription and you will not receive the new editions.

An observer design pattern is not limited to the newsletter subscription but it is a good life example.


Comments

Popular posts from this blog

Debug Java Stream in Intellij Idea

Creating Efficient Docker Images with Spring Boot 2.3

CRUD Goes Even Easier With JPABuddy