- Data Sharing
- The Publish-and-Subscribe Model
- Observers
- The ObserverEntity Class
- The Observer Pattern and the Java Language
- Messages from the Publisher to the Subscribers
- Separation of Concerns
- Running the Code
- Conclusion
- References
Messages from the Publisher to the Subscribers
Nowadays, when writers discuss object-oriented operation they rarely use the term message. Instead, they prefer to talk about method calling. In other words, when object X calls a method in object Y, the mechanism is described purely as one of method calls rather than message passing.
In object-oriented terms, object X is in fact sending object Y a message. In the case of the observer pattern, it’s useful to think of the observable entity as sending messages to the observers. Using the traditional approach with reference to the observer pattern, when a change occurs to the key data and the notification cycle starts, we can think of it as the observable object sending the new data to the observers.