MVC - The Art of Model, View and Controller

September 2, 2011, 6:49 pm

<< Back

After a productive 7 weeks, I successfully completed my internship and can now proudly add around 4-5 new technologies to my resume. One incredible coding practice I learned - and one I didn't even hear about prior to my internship - is coding using the MVC method.

When researching MVC, most sites I browsed just threw graphs and technical definitions at me - but only when I started using it did I understand the true magic of MVC. This is the way I have come to understand it:

MVC is an acronym for ModelView and Controller, which are usually three directories on your server that perform specific tasks. It additionally separates your program into three elements which organizes all the code and files.

This may be a good comparison to explain how MVC works in a practical situation:

The Model in MVC can be related to the storyboarding and scripting in video production. It provides all the necessary information which will help guide the production. The director is like the controller - they have the control over production by saying what goes where and have the ability to manipulate anything they want. The view is like the cinematographer who takes the instructions from the director and decides what everything is going to look like.

In web development, the model – just like the preproduction stage of filming – decides what information is needed for the website. It pulls the data from the database and sends it to the controller which manipulates it. The controller then sends the finalized data to the view which contains the front-end code (CSS and XHTML).

This is incredibly useful for many reasons. The designers only have to worry about the view, so they don’t see any of the programmer’s code; likewise, the programmer only has to worry about the model and controller. This keeps code clean, and separates each component of a web application. 

It really is amazing!

Add Comment:

View Comments:

No comments have been submitted. Be the first one!