There is no MVC

Posted by Scato Eggen on 19 July 2010

Tag(s): Webapplicaties, Artikel, Desktop

The MVC-paradigm has been around since the dawn Object-Oriented Programming (OOP). Meanwhile lots of frameworks have adopted this paradigm in some form, and while I was working on my own server-side JavaScript framework (work in progress) I decided to adopt it as well. So what is MVC?

MVC was created by Trygve Reenskaug around 1979 and stands for Model-View-Controller. So far nothing new, you can read about this on wikipedia. What it doesn't say is why Reenskaug created this pattern. Smalltalk was one of the first Object-Oriented Programming languages. OOP was supposed to change the world: no more spaghetti code, ultimate maintainability. Of course this was an illusion, so what does it take to make an application suitable for continuous growth? Reenskaug's answer was: MVC. (Actualy, it was a bit longer, but that's besides the point.)

Thirty years later, nobody uses smalltalk anymore, but everybody uses MVC. Even web application frameworks like Spring, Ruby on Rails and Zend Framework use MVC. Web applications weren't around in 1979, so what should a web application controller look like? What's a controller anyway?

Well... in smalltalk a controller used to be the object that contained the event loop. Event detection was delegated to subclasses. This used to be something you had to work out as a programmer yourself. (See Burbeck.) Luckily, GUI frameworks like Swing do all the event detection. We don't write event loops anymore. Dispatching HTTP requests is not something you'd call event detection, but it's exactly the thing a web application controllers should do. Things have changed.

So is MVC still relevant today? Shouldn't we move on? It all depends on wether you want to change the definition of MVC or if you want to replace MVC by, say, Model-View-Presenter (MVP). Martin Fowler says even MVP is outdated and that the main point is to write a domain model and separate presentation from domain. As long as you stick to this rule, you can choose all kinds of flavours for your controllers and your views. (Look for "passive", "supervising" and "autonomous". See Fowler.)

I agree with Martin Fowler, although I have to say that Mike Potel had some interesting ideas.

Post a comment:

Name:
E-mail*:
Comment:
*optional, will not be published.