Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC vs HMVC for web application development

I'm using MVC pattern for web development. I use codeIgniter framework. I found http://fuelphp.com/ and http://kohanaframework.org/ , they are using HMVC. It still not is clear of HMVC and why we should use HMVC instead of MVC ? I am confused after reading HMVC pattern and it's not too much different from MVC. Can you explain why we should use HMVC for web application development ?

like image 278
saturngod Avatar asked Mar 28 '11 03:03

saturngod


People also ask

What is difference between MVC and HMVC?

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.

Is MVC good for web development?

MVC platform supports the development of SEO friendly web pages or web applications. Using this platform, it is very easy to develop SEO-friendly URLs to generate more visits from a specific application. This development architecture is commonly used in Test-Driven Development applications.

Why use HMVC?

Why should I use HMVC? Key advantages to implementing the HMVC pattern in your development cycle: Modularization: Reduction of dependencies between the disparate parts of the application. Organization: Having a folder for each of the relevant triads makes for a lighter work load.

What is HMVC in laravel?

HMVC is a real effective design pattern and has been widely used, however among Laravel's community, this design pattern is considered somehow a “bad practice”. In his book From Apprentice to Artisan, Taylor Otwell – Laravel Framework Author- suggests: HMVC is usually an indicator of poor design.


1 Answers

HMVC can do anything that MVC can and more

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

in HMVC (Hierarchical Model View Controller) you can do that , i would sum all the qualities 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 trying HMVC here is a picture to be more clear

See picture

for CodeIgniter use "Modular Extensions - HMVC"

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

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

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

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

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

https://www.youtube.com/watch?v=8fy8E_C5_qQ&list=PLBEpR3pmwCawDZ6FgNYoyvicEz4HrJPec&index=1

hope that helps!

like image 137
Nassim Avatar answered Oct 06 '22 09:10

Nassim