Push versus Pull
One big problem with the Observer pattern that we have looked at so far is that the Update method in the base class is limited. In our case, it can only be used with Observers that expect two floats. If we want a different style of Observer, we need to create a new Observer class and a new Subject to work with it.
This Push version of the pattern is great because the classes are completely decoupled. The derived classes don't need to know about each other at all. The price to pay for this decoupling is that we need to write lots of Subject and Observer base classes for each method signature we want to use. An alternative version of this pattern lets the Observers pull the data they want from the Subject. In the Pull version, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access