Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Email Address:

HMVC: The layered pattern for developing strong client tiers

This hierarchical model eases the development of a Java-based client tier

Print Email Feedback Resources Discuss
Digg Reddit SlashDot Stumble del.icio.us Technorati dzone
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 GUI? 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 -- MVC

Developers primarily use MVC in Smalltalk for implementing GUI objects. Numerous GUI class libraries and application frameworks have reused and adopted the pattern. As the MVC paradigm offers an elegant and simple means for solving UI-related problems in an object-oriented way, its popularity is justified. MVC provides clearly defined roles and responsibilities for its three constituent elements -- model, view, and controller. The view manages the screen layout -- that is, what the user interacts with and sees on the screen. The model represents the data underlying the object -- for example, the on-off state of a check box or the text string from a text field. Events cause the data in the model to change. The controller determines how the user interacts with the view in the form of commands.

Print Email Feedback Resources
Digg Reddit SlashDot Stumble del.icio.us Technorati dzone
Comment
Welcome, Logout
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
Download the complete source code of this article as a zip file
http://www.javaworld.com/jw-07-2000/hmvc/jw-0721-hmvc.zip
This article presupposes familiarity with the MVC paradigm, and an understanding of issues related to developing a Java-based client tier. If you would like to read more about client-tier frameworks, MVC, and MVC variants, you may find the following resources helpful: "Application Programming in Smalltalk-80How to use Model-View-Controller (MVC)," Steve Burbeck (1992)
http://st-www.cs.uiuc.edu/users/smarch/st-docs/mvc.html
"MVPModel-View-Presenter -- The Taligent Programming Model for C++ and Java," Mike Potel (1996)
http://www.ibm.com/java/education/mvp.pdf
"MVC-ClientPutting Model-View-Controller to Work," Rick Sanderson (1999)
http://www.fourbit.com/resources/fab_mvc_clients.htm
More on client-side frameworks and other related topics
http://www.javapal.com/KBLinks.htm#FRAMEWORKS



You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser