next up previous contents
Next: Widget Up: Model/Framework Previous: App

Interface

The interface component is the platform specific component that maintains a collection of interface widgets. However, instantiating a collection of widgets is not the only task that the interface is responsible for. Often, there are dependencies between widgets. For instance, there may be a reset button that resets the other widgets.

The naive way to implement dependencies would be to have each widget keep track of its dependents. Then each widget could notify its dependents when a dependency applied. Using this type of approach makes the interface less reusable. The more dependencies there are, the less likely it is that you can remove or add widgets or even pull out widgets and use them elsewhere. Instead, you have a bunch of very specialized widgets that work with a particular interface setup.

The solution to this problem is to use an interface mediator. The interface mediator is a central object that instantiates the widgets and maintains all of the dependencies between them. The widgets do not know about each other, they only know about a mediator. Whenever a widget changes, it only notifies the mediator. The mediator then decides what should happen to any other widgets if anything at all. As a result, the widgets are very reusable. Any of the ugliness specific to a particular interface is hidden within the interface mediator. This makes the interface mediator specific to a particular interface setup. There is a interface mediator abstraction, but each new interface must implement a concrete interface mediator.

Using a mediator promotes loose coupling between the user interface objects. It localizes behavior in a central object. However, the drawback is that often the mediator itself becomes a complicated object that is hard to maintain.



Paul John Rajlich
Mon May 4 16:53:57 CDT 1998