in the general case, you should update everything that can be observed when you receive a call to update (). if this is not practical, you can pass the notifyObservers () hint.
the bandit of the book says that one of the consequences of the observer pattern:
“Unexpected updates. Since observers do not know about each other, they may be blind to the maximum cost of changing an item. Apparently, a harmless operation on this issue can cause a cascade of updates for observers and their dependent objects. Moreover, dependency criteria that are not defined or maintained, usually lead to false updates that are difficult to track.
This problem is compounded by the fact that a simple update protocol does not contain details about what has changed in the topic. Without an additional protocol, to help observers discover what has changed, they may be forced to work to push the changes. "also in the implementation process, they say:
"Avoid specific observer update protocols: push and pull models. Implementations of the Observer pattern often provide the object with additional information about the change. The subject passes this information as an argument for updating. The amount of information can vary widely.
At some extreme, which we call the push model, the subject sends observers detailed information about the change, whether they want it or not. On the other hand, a traction model; the subject sends only the most minimal notification, and observers ask for further details.
The traction model emphasizes the subjective ignorance of its observers, while the push model assumes that objects know something about the needs of their observers. The push model can make observers less reusable because Subject classes make assumptions about Observer classes that may not always be true. On the other hand, the pull model can be inefficient because the Observer classes need to figure out what has changed without Subject's help. "
Ray tayek
source share