Hierarchical Model–view–controller
   HOME

TheInfoList



OR:

Hierarchical model–view–controller (HMVC) is a software
architectural pattern An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. The architectural patterns address various issues in software engineering, such as computer hardware perform ...
, a variation of
model–view–controller Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of infor ...
(MVC) similar to presentation–abstraction–control (PAC), that was published in 2000 in an article in
JavaWorld ''InfoWorld'' (abbreviated IW) is an information technology media business. Founded in 1978, it began as a monthly magazine. In 2007, it transitioned to a web-only publication. Its parent company today is International Data Group, and its siste ...
Magazine, the authors apparently unaware of PAC, which was published 13 years earlier. The controller has some oversight in that it selects first the model and then the view, realizing an approval mechanism by the controller. The model prevents the view from accessing the data source directly.


Example

The largest practical benefit of using an HMVC architecture is the "widgetization" of content structures. An example might be comments, ratings, Twitter or blog RSS feed displays, or the display of shopping cart contents for an e-commerce website. It is essentially a piece of content that needs to be displayed across multiple pages, and possibly even in different places, depending on the context of the main HTTP request. Traditional MVC frameworks generally do not provide a direct answer for these types of content structures, so programmers often end up duplicating and switching layouts, using custom helpers, creating their own widget structures or library files, or pulling in unrelated data from the main requested Controller to push through to the View and render in a partial. The downside is that the responsibility of rendering a particular piece of content or loading required data leaks into multiple areas and gets duplicated in the respective places. HMVC, or specifically the ability to dispatch sub-requests to a Controller to handle these responsibilities aims to solve this problem. The structure mimics that of traditional MVC. For example, if one needs to load some data about comments, and display them in HTML format, one would send a request to the comments Controller with some parameters. The request then interacts with the Model, picks a View, which displays the content. The difference from a traditional MVC is that instead of displaying the comments in a fully separate page, they are displayed inline below the article the user is viewing. In this regard, HMVC strives to increase code
modularity Broadly speaking, modularity is the degree to which a system's components may be separated and recombined, often with the benefit of flexibility and variety in use. The concept of modularity is used primarily to reduce complexity by breaking a sy ...
, aid reusability, and maintain a better separation of concerns.


See also

* Presentation–abstraction–control (PAC) *
Model–view–controller Model–view–controller (MVC) is a software architectural pattern commonly used for developing user interfaces that divide the related program logic into three interconnected elements. This is done to separate internal representations of infor ...
(MVC)


References

{{DEFAULTSORT:Hierarchical model-view-controller Software analysis patterns