This post originated from an RSS feed registered with Ruby Buzz
by David Heinemeier Hansson.
Original Post: MVC: In layman's terms
Feed Title: Loud Thinking
Feed URL: http://feeds.feedburner.com/LoudThinking
Feed Description: All about the full-stack, web-framework Rails for Ruby and on putting it to good effect with Basecamp
MVC is a pattern for separating the three basic concerns of a web application into isolated tiers, which can be constructed, tweaked, and tested apart from the others. MVC is short for Model, View, Control.
The model is composed of business classes, such as Person, Project, Account. The Project class has methods like has_milestones?, save, get_project_lead, and so on. This is the world of abstract ideas in a Plato-sense of ideals.
The view is the HTML templates that knows how to format and display the model objects, like "Title: <%= @post.title %>" (which shows the title of the post object). There's no computations and very little logic in the templates (or at least that's the way it should be).
The controller ties the view and model together by determining which models to give to which view and a given request. Or how to update the model as a request prescribes and redirect the user some where.
This might appear as a somewhat elaborate scheme. And in a way, it is. You probably wouldn't structure your guest book application like this. Having it all mashed together is fine for that.
But as soon as your application grows to even a moderate level of complexity, there's an incredible benefit to be found in the MVC approach (or similar patterns for separating concerns). You decrease duplication, promote coherence and clarity, make it possible to test, and a world of other benefits.
Since all MVC-style applications relies on a number of shared principles, it's possible to abstract and reuse these in what's called a framework. Rails is such a framework that tries to remove the complexity and drudgery of MVC, while still allowing you to realize all the benefits.
This description is a reprint from the discussion of Ruby on Rails to Basecamp from Signal vs Noise.