Being someone very interested in the principles of MVC (Model-View-Controller) Development, I was amused to see that there is very little written out here on the internet that actually makes sense. Most articles or tutorials use terms like “business logic” without really defining what it means, which makes understanding MVC all the more difficult. Others simply gloss over what an architectural pattern is without really explaining why you would care about it. It is my hope that I can attempt to explain everything you need to know about MVC in the simplest possible way.

My perspective on MVC is through PHP – my scripting language of choice Rapid Application Development in PHP Frameworks. What I have learned about MVC in that time is that it is very powerful, scalable, clean, and if well-coded, robust. The reason that such respected frameworks like Ruby On Rails and Zend Framework use the principles of MVC alone should be a hint that there is something special involved here.

For those of you who are not aware, MVC was originally described in terms of a design pattern for use with Smalltalk by Trygve Reenskaug in 1979. His paper was published under the title “Applications Programming in Smalltalk-80: How to use Model-View-Controller”, and paved the groundwork for most future MVC implementations.

MVC, or Model-View-Controller is a software architecture, or design pattern, that is used in software engineering, whose fundamental principle is based on the idea that the logic of an application should be separated from its presentation. Put simply, I would say that MVC is simply a better way of separating the logic of your application from the display.

A simple way to think of this would be to consider the following:

  • A user interacts with the view – by clicking on a link or submitting a form.
  • The Controller handles the user input, and transfers the information to the model
  • The Model receives the information and updates it’s state (adds data to a database, for example, or calculates todays date)
  • The View checks the state of the Model and responds accordingly (listing the newly entered data, maybe)
  • The View waits for another interaction from the user.