Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hierarchical MVC: What, Why & How

94cb827736e36e0f6343e9640e72fec7?s=47 vlucas
March 02, 2012

Hierarchical MVC: What, Why & How

94cb827736e36e0f6343e9640e72fec7?s=128

vlucas

March 02, 2012
Tweet

Transcript

  1. Hierarchical MVC What, Why, and How Vance Lucas (@vlucas) Friday,

    March 2, 2012
  2. Who am I? • Vance Lucas • http://vancelucas.com • @vlucas

    • Business: http://brightb.it • Oklahoma City • Web developer since 1999 (PHP3) • PHP, JavaScript, Ruby / Web & Mobile Friday, March 2, 2012
  3. What is HMVC? Friday, March 2, 2012

  4. Multiple MVC triads working together to compose a single HTTP

    Response for a single HTTP Request Friday, March 2, 2012
  5. Multiple MVC Triads, Single Response http://techportal.ibuildings.com/2010/02/22/scaling-web-applications-with-hmvc/ Friday, March 2, 2012

  6. Properties of HMVC • Many MVC triads working together •

    Separation of responsibilities of display • Modularization of content & display types Friday, March 2, 2012
  7. HMVC is the “widgetization” and modularization of content Friday, March

    2, 2012
  8. Modular MVC Triads Friday, March 2, 2012

  9. A quick note on HMVC... Friday, March 2, 2012

  10. Most HMVC implementations are not actually Hierarchical Friday, March 2,

    2012
  11. A more useful term might be Nested MVC when no

    hierarchy is tracked or enforced Friday, March 2, 2012
  12. Why HMVC? Friday, March 2, 2012

  13. HMVC design promotes broader code re-use and separation of responsibilities

    though natural organization and dispatching of MVC triads Friday, March 2, 2012
  14. Instead of using partials and shared template fragments, just pass

    the responsibility to another MVC triad Friday, March 2, 2012
  15. <Thing> should know how to render <Thing> Friday, March 2,

    2012
  16. Benefits of HMVC • Shift the responsibility of the display

    and logic down to a self-contained MVC structure • Eliminate repetitive code in controllers passing data to templates and templates passing data to and rendering partials • Call directly in view where needed for display • Built-in widget-like structures • Keep extra business logic contained inside module that deals with it Friday, March 2, 2012
  17. How do I use HMVC? Friday, March 2, 2012

  18. Anywhere you would use a widget or related but separate

    content type on a page Friday, March 2, 2012
  19. Any Shared Content Type • Comments • Tags / Tag

    Clouds • Ratings • Shopping Cart Contents • Menus • RSS/Blog Feeds • Calendars • (etc...) Friday, March 2, 2012
  20. How about some Code? Friday, March 2, 2012

  21. Modular MVC Triads Friday, March 2, 2012

  22. Alloy HMVC Example Friday, March 2, 2012

  23. Kohana 3.0 HMVC Example Friday, March 2, 2012

  24. Symfony 2 HMVC Example Friday, March 2, 2012

  25. Demo Code! Friday, March 2, 2012

  26. hello@brightb.it http://brightb.it (405) 595-0011 Oklahoma City Friday, March 2, 2012