Skip navigation.

Is MVC over-designed crap?

Adam Bosworth talked recently about the KISS principle, and I asked the readers how much of their code was over-designed crap. Here's one target.

I have been looking at this SitePoint thread on the Model-View-Controller pattern that demonstrates the large amount of confusion there is over MVC. One of the reasons why I dislike patterns is that so many intelligent people get so confused over concepts like this. To me, what we should look at is the basic reasons why we want to manage web-pages and satisfy them:

  1. centralized control over page rights and access
  2. ability to remap urls due to changes in web-site structure
  3. handling 404-errors intelligently
  4. ability to dynamically add headers and footers to pages for displaying alerts such as "system going down at 5pm"
  5. separates content from presentation in a reasonable manner, eg. with templates
  6. managing tainted data (eg. POSTS, GETS, COOKIES)

Agonizing over whether some page management code conforms to MVC is silly - particularly when most people have only an imperfect understanding of MVC. MVC for example fails to address important issues like 2, 3 and 4 and 6. Good design is about meeting needs in a flexible way, and not conforming to abstract, easily misunderstood concepts.

25 Nov: there have been interesting comments posted already.

27 Nov: Joel Spolsky's article on Architecture Astronerds is worth a read.

28 Nov Postscript: I think that there are many good responses to the original blog post. So I'm happy with the results of this polemic. There were many intelligent posts that reflected on the strengths and weaknesses of MVC. For example, Jason Sweat is considering MVC an anti-pattern, something I never thought about. Azmo mentioned that MVC does not cover the browser well - a perspective that was new to me.

Some people keep on saying that this feature or that is not part of MVC. True, but the point i am trying to make is that a web app pattern that does not cover security, handling of dynamic elements, etc is severely flawed, and saying that these are not part of MVC does not make these difficult issues disappear. Where do they fit into MVC? Are they part of the Model or View or Controller, or are they orthogonal? There is no agreement. MVC is incomplete and incoherent once taken out of the context of smalltalk.

What would be the next step? For me, I'm happy enough to point out that "the emperor has no clothes"; I long ago rejected MVC for the above reasons, and have no desire to use MVC. For MVC advocates, I would encourage you to post your ideas (on your blogs) on where everything should fit on. Some of you might have already implemented solutions, but i think to ask others to read your code is probably too hard - it is better to explain your designs.

Lastly, is MVC overdesigned crap? Well i was wrong about overdesign -- it's actually underdesigned. Is it crap? That remains to be seen.

30 Nov: Jeff Moore posts an interesting response on the value of MVC. And the MVC definition is definitely good stuff. Perhaps Harry needs to rewrite some of the phppatterns MVC articles.