HMVC: The Layered Pattern for Developing Strong Client Tiers, Part 1 This hierarchical model eases the development of a Java-ba

The task of designing and developing the client tier of an n-tier Web

architecture often challenges developers. This is particularly true in

the Web world, where the sheer variety of servers, deployment

platforms, and protocols turns the challenge into a headache. A client-

tier architect must address a number of questions:

* How should I structure my GUI?

* How will users interact with my GUI?

* How should I separate server-side/transport data formats from my


* How should I provide sound mechanisms for event management,

application flows, and widget control?

In order to understand some of these key issues, we must differentiate

between the presentation layer (or client tier) and the GUI layer. The

GUI layer deals with a small subset of the whole presentation layer,

namely the UI widgets and the immediate effects of user actions -- a

JTextField and its ActionListener, for example. The presentation layer

needs to deal with application flows and server interaction in addition

to providing GUI services. The terms presentation layer and client tier

are used interchangeably in this article.

Framework-based approach

To mitigate the risk associated with creating a robust client tier,

developers have produced several frameworks and design patterns with

varying degrees of success. The Model-View-Controller (MVC) paradigm

remains one of the more enduring patterns. However, the traditional MVC

scope falls short when it comes to the control of GUI elements

(widgets). MVC does not handle the complexities of data management,

event management, and application flows. As an adaptation of the MVC

triad, the HMVC -- Hierarchical-Model-View-Controller -- paradigm seeks

to redress some of the above-mentioned issues. We developed this

pattern during the course of our work in the field. HMVC provides a

powerful yet easy-to-understand layered design methodology for

developing a complete presentation layer. While MVC provides an

efficient framework for developing GUI interaction, HMVC scales it to

the entire client tier. Some key benefits of a responsibility-based,

layered architecture include:

* Defined intralayer communication and isolation from higher layers

* Defined interlayer communication with minimal coupling

* Localization of exposure to third-party code

This article explores the application of the HMVC design pattern in the

development of a Java-based client-tier infrastructure.

Note: The entire source code for this article can be downloaded as a

zip file from the Resources section below.

Model view controller

ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon