开发者

Accurate use / consumption of the HMVC pattern?

开发者 https://www.devze.com 2023-03-28 16:25 出处:网络
I am trying to understand HMVC and how or if I should consider it in my current MVC app. Regarding this quote from [this][1] question about MVC architecture,

I am trying to understand HMVC and how or if I should consider it in my current MVC app.

Regarding this quote from [this][1] question about MVC architecture,

Sometimes the Hierarchical-Model-View-Controller (HMVC) pattern (aka Presentation-Abstraction-Control) is a good choice for dealing with more complex interface and application demands.

"However, the traditional MVC scope falls short when it comes to t开发者_运维技巧he 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."

Jason Cai, Ranjit Kapila, and Gaurav Pal (July 2000). "HMVC: The layered pattern for developing strong client tiers". JavaWorld Magazine.

[1]: https://stackoverflow.com/questions/113602/when-to-use-mvc-architecture

I have been trying to understand PAC/HMVC, and the above text struck a chord. The triad abstraction of HMVC can be applied to "widgets" on a page, or how in using the ASP.Net view engine (vs the Razor view engine), would translate to "controls" on the page.

Would that be an accurate application of the HMVC pattern?

If so, I'm not sure exactly how that would be implemented. I do see the advantages of this, in that if the main page loads fine, and some of the user controls/widgets error-out, the page still loads.

So the main page controller would make the call to its widgets controllers? From the main view, I am guessing that model inheritance would come into play, just as you would consume the model's objects in the view of a simple MVC page.

What would that look like in code - calling the model data from say two or three triads down the chain from a top-level view?


Firstly, you raise some interesting points. Secondly, I am making the assumption you are familiar with the ASP.NET MVC Framework.

Just thinking out loud here, there is a HtmlHelper called Partial(), which takes a controller and action and returns the result. So, if you write an Action that returns a PartialView (which could be used a widgets - you can have multiple per page), could this be a plausible implementation of the architecture above?

Thanks,

Matt


After reading different resources of HMVC, I believe ASP.NET MVC does have HMVC since v2.0 in the form of Areas.

Couple that with T4MVC and calling Action.PartialX() methods and you've got yourself the next buzz-word HMVC.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号