[ACCEPTED]-MVC vs HMVC for web application development-hmvc

Accepted answer
Score: 41

HMVC can do anything that MVC can and more

one of the things that you will or had struggled 22 with in MVC is that you can't call a controller 21 from another controller (unless you use 20 a custom library or helper to do that)

in 19 HMVC (Hierarchical Model View Controller) you 18 can do that , i would sum all the qualities 17 in here:

  • reuse your code in other projects
  • simplify maintaining your project
  • scale your project
  • organize code
  • modular structure

you will never go back to MVC after 16 trying HMVC here is a picture to be more 15 clear

See picture

for CodeIgniter use "Modular Extensions 14 - HMVC"

Modular Extensions makes the 13 CodeIgniter PHP framework modular. Modules 12 are groups of independent components, typically 11 model, controller and view, arranged in 10 an application modules sub-directory that 9 can be dropped into other CodeIgniter applications.

Module 8 Controllers can be used as normal Controllers 7 or HMVC Controllers and they can be used 6 as widgets to help you build view partials.

if 5 you want to use codeigniter with HMVC pattern, you 4 can use Modular Extensions - HMVC here


and 3 here are some nice and funny video tutorials 2 that will get you on rails with HMCV in 1 codeigniter


hope that helps!

Score: 23

The Hierarchical-Model-View-Controller (HMVC) pattern 30 is a direct extension to the MVC pattern 29 that manages to solve many of the scalability 28 issues already mentioned. HMVC was first 27 described in a blog post entitled HMVC: The layered pattern for developing strong client tiers on 26 the JavaWorld web site in July 2000. Much 25 of the article concentrates on the benefits 24 of using HMVC with graphical user interfaces. There 23 has been some suggestion that the authors where actually 22 re-interpreting another pattern called Presentation-Abstraction-Control 21 (PAC) described in 1987. The article in 20 JavaWorld provides a detailed explanation 19 of how HMVC can aid in the design of desktop 18 applications with GUIs. The focus of this article 17 is to demonstrate how HMVC can be used to 16 create scalable web applications.

HMVC 15 is a collection of traditional MVC triads 14 operating as one application. Each triad 13 is completely independent and can execute without 12 the presence of any other. All requests 11 made to triads must use the controller 10 interface, never loading models or libraries outside 9 of their own domain. The triads physical 8 location within the hosting environment 7 is not important, as long as it is accessible 6 from all other parts of the system. The 5 distinct features of HMVC encourages the 4 reuse of existing code, simplifies testing 3 of disparate parts of the system and ensures 2 that the application is easily enhanced 1 or extended.

From Scaling Web Applications with HMVC by Sam de Freyssinet

More Related questions