| writing that puts story first

Filed Under: design
Tagged As: , , , ,

MVC, Model-View-Controller is a design practice theory that, according to Wikipedia, was pioneered by one Trygve Reenskaug in 1979 as method for developing object-oriented in a smart fashion. How smart? The development of any project is broken down into three separate areas, each of which can independently be changed without affecting any of the others.

Simple right?

Simple right?

Modelto put it bluntly, this is the raw data. For many websites, this is your database, the raw or stored data that is to be rendered into usable presentable content by the website. See updated section below

View – as the name suggests, this is the outward looking portion of a website or application, typically, this is the graphic user interface (GUI). Many developers are loathe to admit this, but the “pretty” is often how people judge an application.

Controllerthe final, and arguably the most important part of the trifecta that is MVC, the controller aspect is what makes the application actually work. See updated section below.

MVC has recently come back into popularity in a major way due to two main things. First, would be OSX. When Jobs decided to scrap OS9 and all prior work, and instead borrow from the OpenSource community and his work at NeXT, it was determined that OSX would basically force programmers to use the MVC pattern when developing software. This was largely to allow OSX to dictate the View section, thus assuring a standard look and feel through all software running on Macs.

The other is the internet darling that is Ruby-on-Rails. RoR is, of course, everywhere based largely on the ease with which new programs can be made. Case in point is typically Twitter, which was purportedly built from spec in less than two weeks. While RoR doesn’t have any special abilities (that I’ve seen in my limited developers knowledge), because it forces developers to use MVC, mistakes which would ordinarily weigh down a development process are severely reduced.

Why take all this time to delve into the details of MVC? Because I’m firmly in the V category. Even though I’ve been building websites for several years now I’ve restricted my work to two main areas – designing static websites through a combination of CSS and X/HTML and templating various OpenSource packages (mainly Wordpress and Joomla).

Just as I got into designing webpages because the built in blogspot templates didn’t satisfy how I wanted to present myself online, I am now in a position where the content management systems I use (Wordpress for this site) isn’t adequate in it’s current form. Yes, Wordpress is very extensible through third party plugins. The downside is that these plugins often don’t do exactly what is required or do more than needed. So, just as I did when I started learning basic design skills so many years ago, the V if you will, I’m now moving comfortably towards the C.

First up is the language of the software that I most frequently work in, PHP, and by extension, becoming more familiar with MySQL databases (that’s the M, for those keeping score). Why? In the end, it pays to be the entire product cycle when you’re working for yourself. Or to put it more bluntly, I’ll be more of an internet badass.

Update

Got a nice block of instructrion from aut0poietic which corrected some of the over generalizations I used in the definitions for Model and Controller. Here are more correct definitions:

Model: The model is not just the database, it’s the Data Access Layer. It’s typically an Object (capital O) that has been built expose a generalized API specific to the Application. A Wordpress Model Object would have an API with methods like “getPost()”. getPost would return a Post Object that encapsulates the data.

Controller - It’s basically a traffic cop — directing messages back and forth. In a true MVC application, the Controller is painfully stupid: It does little more than send messages to the View when the Model updates, and the Model with the View updates. What it does contain is business logic, so that it sends the correct message, with the correct information based on business decisions.

And on why Wordpress is not a true MVC pattern: Template files should be View, but instead it’s a mash of view and controller. The Loop *should not* exist in the View. The view should not reach out to the Model and get data, nor should it submit data.