tags:

views:

898

answers:

3

Reading Kohana's documentation, I found out that the main difference in 3.0 version is that it follows the HMVC pattern instead of MVC as version 2.x does. The page about this in Kohana's docs and the one on wikipedia didn't really give me a clear idea.

So question: what is the HMVC pattern and how does it differ from MVC?

+1  A: 

HMVC is closely related to the "component based" approach to dispatching. Basically, instead of having a single dispatcher, which delegates to a controller, each controller can act as a dispatcher it self. This gives you a hierarchy of controllers. The design is more flexible and causes better encapsulation of code, but at a price of higher abstraction. Konstrukt is designed around this pattern.

See also this answer: http://stackoverflow.com/questions/115629/simplest-php-routing-framework/120411#120411

troelskn
+13  A: 

Sam de Freyssinet (one of the Kohana developers) wrote a rather in-depth article about HMVC, what it is, and how it can be used. Take a look over at: http://techportal.ibuildings.com/2010/02/22/scaling-web-applications-with-hmvc/

shadowhand
Thanks, great link
kemp
Great article. Every Kohana developer should read this.
Gerry
+1  A: 

I think the "H" in "HMVC" is somewhat unnecessary and confusing. In Kohana, at least, it seems that an "HMVC" request is not really anything more exciting than a HTTP request that happens to be serviced internally: instead of being issued over the network, it's a request routed and dispatched by the framework itself. There's no particular requirement or need that the requests form a hierarchy (other than the standard call graph of every imperative program); the requests could easily be recursive, for example.

The advantage of this architectural style is that since the same "calling convention" is used for internal and external requests, it's trivial to convert "internal" service requests to "external" requests or vice versa as the need arises.

mjs