34.4. Model-View Separation and "Upward" Communication
How can windows obtain information to display? Usually, it is sufficient for them to send messages to domain objects, querying for information which they then display in widgetsa polling or pull-from-above model of display updates.However, a polling model is sometimes insufficient. For example, polling every second across thousands of objects to discover only one or two changes, which are then used to refresh a GUI display, is not efficient. In this case it is more efficient for the few changing domain objects to communicate with windows to cause a display update as the state of domain objects changes. Typical situations of this case include:
- Monitoring applications, such as telecommunications network management.
- Simulation applications that require visualization, such as aerodynamics modeling.
In these situations, a push-from-below model of display update is required. Because of the restriction of the Model-View Separation pattern, this leads to the need for "indirect" communication from lower objects up to windowspushing up notification to update from below.There are two common solutions:
- The Observer pattern, via making the GUI object simply appear as an object that implements an interface such as PropertyListener .
- A UI facade object. That is, adding a facade within the UI layer that receives requests from below. This is an example of adding Indirection to provide Protected Variation if the GUI changes. For example, see Figure 34.13.
Figure 34.13. A UI layer UIFacade is occasionally used for push-from-below designs.