Miscellaneous Code

  Home arrow Miscellaneous Code arrow A Sample Web Application with the HMVC...
MISCELLANEOUS CODE

A Sample Web Application with the HMVC Design Pattern
By: Alejandros Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2010-03-31

    Table of Contents:
  • A Sample Web Application with the HMVC Design Pattern
  • Review: the framework's previous model class
  • Building a basic HMVC-based application
  • Building model classes for database records

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    A Sample Web Application with the HMVC Design Pattern


    (Page 1 of 4 )

    In this seventh part of a nine-part series on the hierarchical model-view-controller design pattern, I start building an example MySQL-driven application. Its main task will consist of displaying a simple web page with data fetched from two different database tables.

    Frankly speaking, learning the key concepts that surround the implementation of the Model-View-Controller paradigm in PHP 5 can be a pretty challenging task, particularly for those programmers taking their first steps in the huge (and sometimes esoteric) arena of design patterns. While a few, like Singleton or Factory, are relatively simple to grasp, the MVC pattern presents a steeper learning curve, as it requires modifying and restructuring the way that web applications should be developed.

    However, not everything is so intimidating and scary when it comes to mastering the foundations of this architectural pattern. The web is full of tutorials and resources that offer a friendly and spot-on introduction to it, thus making it easier to grab its ins and outs. What's more, many well-established PHP frameworks available nowadays rely heavily on an MVC layer to leverage their full potential; taking a close look at them can be of great help in getting familiar with the pattern's basics as well.

    Yet, one of the neatest things about the MVC paradigm is that it can be taken one step further through a hierarchical implementation, not surprisingly called the "Hierarchical Model-View-Controller" pattern. The HMVC pattern permits you to map single HTTP requests to multiple MVC modules, known in programming jargon as MVC triads.

    The benefits to using the HMVC approach are many and remarkable, since its intrinsic nature allows you to build programs that are (at least in theory) easier to maintain and scale. Of course, it's fair to say that creating applications that will work under an HMVC schema isn't always a silver bullet that will prevent you from writing poor code -- which applies to others areas of web development as well.

    However, the HMVC design pattern is indeed an approach worth looking at, and in this group of tutorials you'll learn how to apply it within the context of an object-oriented framework that can be easily enhanced through your own improvements and tweaks.

    In the last tutorial I finished building the aforementioned framework, so it's time to give it a try and see if it's really capable of running under a fully-functional HMVC schema. With that premise in mind, in the following lines I'm going to use it for building a basic MySQL-driven program, which will generate a dynamic web page through a couple of independent MVC triads.

    To learn more about how this sample program will be developed, go ahead and begin reading!

    More Miscellaneous Code Articles
    More By Alejandros Gervasio

    blog comments powered by Disqus

    MISCELLANEOUS CODE ARTICLES

    - Creating a Web Page Controller with the HMVC...
    - Coding Controllers and Views for the HMVC De...
    - A Sample Web Application with the HMVC Desig...
    - Adding a Class to Parse Views to an HMVC Des...
    - Building a Model Class for the HMVC Design P...
    - Filtering Input Data and Generating HTML For...
    - The HMVC Design Pattern: Working with MySQL ...
    - Dispatching Requests to MVC Triads with the ...
    - Implementing the Hierarchical Model-View-Con...
    - A Web App Based on a Model for the CodeIgnit...
    - Completing a Model for the CodeIgniter PHP F...
    - Validating Input Data with the CodeIgniter P...
    - Deleting Database Records with the CodeIgnit...
    - Inserting Database Records with a CodeIgnite...
    - Fetching Database Rows with a Model for the ...

    Developer Shed Affiliates

     



    © 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap