The Model-View-Controller in Joomla 1.5 PDF Print E-mail
Written by Anton Nikiforov   
Wednesday, 10 September 2008 12:22

Here at WowJoomla we believe that 1.5 is not just a cleanly coded product of genious minds, but rather a new way of thinking for all Joomla developers, the shoulders upon which we can stand and grow.

For many end users, there's not much difference between Joomla 1.0 and Joomla 1.5. But believe me, 1.5 has a strong unrevealed yet potential which will play an important role in Joomla's taking over of CMS market in the following years. And the foundation of the anticipated success of Joomla 1.5 is the Model-View-Controller (MVC) architechture it was built with.

Here's how Trygve Reenskaug, the inventor of MVC, described the concept back in 1979:

  1. Models

    Models represent knowledge. A model could be a single object (rather uninteresting), or it could be some structure of objects.

    There should be a one-to-one correspondence between the model and its parts on the one hand, and the represented world as perceived by the owner of the model on the other hand.

  2. Views

    A view is a (visual) representation of its model. It would ordinarily highlight certain attributes of the model and suppress others. It is thus acting as a presentation filter.

    A view is attached to its model (or model part) and gets the data necessary for the presentation from the model by asking questions. It may also update the model by sending appropriate messages. All these questions and messages have to be in the terminology of the model, the view will therefore have to know the semantics of the attributes of the model it represents.

  3. Controllers

    A controller is the link between a user and the system. It provides the user with input by arranging for relevant views to present themselves in appropriate places on the screen. It provides means for user output by presenting the user with menus or other means of giving commands and data. The controller receives such user output, translates it into the appropriate messages and pass these messages on to one or more of the views.

Long story short, Model stores and manipulates state ("hands"), whereas View renders it to a user ("looks"). Controller receives user input and routes it to a corresponding Model ("brains"). It also decides what View to use

  Model View Controller
The Concept Stores and manipulates state Renders model to a user Receives user input and routes it to a corresponding model. It also decides what view to use
HTML analogue HTML itself CSS Browser
What will it look like in PHP? Classes that store and manipulate data or any of the data itself Classes that populate templates with data and the templates themselves Classes that map incoming HTTP URL requests to handlers and handlers themselves
Why bother? Imagine your application initially stored data in files. After you decided to start storing it in database, all you will need to change is a model View can be modified without affecting the data Controller synchronizes model and view
What Joomla! classes actualize MVC architecture? JModel JView JController

Next time we'll create a simple Joomla component with MVC. In the meantime, enjoy the funny MVC tune, written by James Dempsey! :)

After you have dugg this post, please click this link to check if you qualify to receive a free copy of Digg Motivator!

Last Updated ( Tuesday, 01 July 2008 10:12 )
 
More Articles...
«StartPrev12NextEnd»

Page 1 of 2

Free Downloads

 Login Box

Subscribe to Wowjoomla RSS feed

Increasing competition amongst web hosting companies has made it very easy for customers to select cheap web hosting package according to their requirement.