请输入您要查询的百科知识:

 

词条 Hierarchical model–view–controller
释义

  1. Example

  2. See also

  3. References

Hierarchical model–view–controller (HMVC) is a software architectural pattern, a variation of model–view–controller (MVC) similar to presentation–abstraction–control (PAC), that was published in 2000 in an article[1] in JavaWorld Magazine, the authors apparently unaware[2] 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.[3] 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, aid reusability, and maintain a better separation of concerns.

See also

  • Presentation–abstraction–control (PAC)
  • Model-view-controller (MVC)
  • HMVC[4] on Codeigniter
  • HMVC using the ColdBox Framework and ColdBox Modules

References

1. ^{{cite journal | journal = JavaWorld | url = http://www.javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc.html | title = HMVC: The layered pattern for developing strong client tiers |author1=Jason Cai |author2=Ranjit Kapila |author3=Gaurav Pal |date=July 2000 | accessdate = 2006-05-25 }}
2. ^{{cite journal | journal = JavaWorld | url = http://www.javaworld.com/javaworld/jw-09-2000/jw-0908-letters.html | title = Is HMVC PAC? (letter to the editor) | author = "TP" | year = 2000 | accessdate = 2006-05-25|archiveurl = https://web.archive.org/web/20050205080537/http://www.javaworld.com/javaworld/jw-09-2000/jw-0908-letters.html |archivedate = 2005-02-05}}
3. ^{{cite journal | journal = StackOverflow | url = https://stackoverflow.com/questions/2263416/what-is-the-hmvc-pattern/5736164#5736165 | title = why HMVC pattern? | author = Vance Lucas |date=April 2011 | accessdate = 2013-10-15 }}
4. ^{{Cite web|url=https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc|title=HMVC using Codeigniter|date=|website=|publisher=|access-date=}}
{{DEFAULTSORT:Hierarchical model-view-controller}}

1 : Software analysis patterns

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/25 14:23:22