Managing Your Views with View Handler

Sometimes, the objects that your application needs to manage are multiple views. The views might be views in the MVC architecture (see Chapter 13) or intermediate-level agents in a PAC architecture (see Chapter 14). This pattern can help with views in either of those architectures, but it isn't limited to those two patterns. Here's how the View Handler pattern helps them:

  • Model-View-Controller (MVC): The View Handler pattern refines and explains the relationship between the model and related views.
  • Presentation-Abstraction-Control (PAC): View Handler is important in PAC for coordinating multiple views. Intermediate-level PAC agents correspond to View Handler because they manage view elements. The bottom-level PAC components — components that are primarily involved with views — represent the view components of the View Handler pattern.

There are several reasons to add a manager for the views:

  • The interactions with the views should be handled consistently so that the system is easy for both users and software clients to use.
  • You don't want to merge the code for each view, because it's independent of the other views' code.
  • Tying the code for the views to the management code isn't good. In systems with multiple views, the system should make adding new views in the future easy.

Looking inside View Handler

The View Handler structure involves four types of classes:

  • ViewHandler is the most important class discussed here.
  • Views are implemented ...

Get Pattern-Oriented Software Architecture For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.