MVC is Overrated

The Model-View-Controller Pattern (MVC) is not the only game in town.  In fact it is awkward and cumbersome in some cases.

MVC is a Design Pattern, and Design Patterns show us how to solve common problems with common solutions.   However we should not just use them directly all the time – but rather learn from them and use them as reference points for solving problems.

The most worthwhile component of MVC is the Model, (or Data Layer).  It makes good sense to isolate it and encapsulate it.   It make for very robust and reusable code.  All your SQL related calls should be in one place.

Code above the Data Layer can express itself in more business friendly terms, ie.  book = Book(‘Moby Dick’), and not ‘select * from books where title like ‘%moby dick%’, and status_id = 1;’

In MVC the View and the Controller components are isolated and encapsulated.   I disagree — This can makes simple tasks harder. Views and Controller functionality should be able to commingle.  This is were a lot of the interesting and sophisticated coding happens.

For Web Applications its HTML, CSS, Javascript, and AJAX that we use to communicate with the User.  We should come up with our own patterns that best suite our needs.

4 thoughts on “MVC is Overrated”

  1. MVC is a pattern and there are reasons to use or not use it. MVC is just one common convention of organizing code. And as long as your project has some type of consistent convention you can maintain it fairly easily.
    That said I disagree on the part with the most value. I personally believe that splitting the UI out into it’s own section is the most valuable part. Maintaining a UI that’s easily tweakable is very different than maintaining backend code. Front-end frameworks like Bootstrap and Foundation has made it much easier to do. Do you really want to intermix your business logic with your UI logic?

  2. Thanks @Thomas for you comments, I’m sure many would agree.

    I prefer to generate HTML dynamically rather than using templates where possible. There are a lot of libraries that do that. By generating the HTML you have more process power over it. You also don’t need to hand write all the HTML. Its much easier.

    The business logic of the controller attached to the view does want to be married to its output. It could be a thin wrapper around some other logic which furnishes the data, suitable for any purpose, including text, csv, graphing, etc as well as HTML.

Leave a Reply

Your email address will not be published. Required fields are marked *