Model/View/Template or Model/View/Controller?

Bill de hÓra has a nice piece on Struts 1 that touches on something about MVC that I’ve never quite liked in the web application context:

In pattern language terms, the MVC pattern has been reapplied to the Web domain without consideration for the forces induced by the Web. MVC frameworks tend to be inwardly focused contraptions of server sided redirects. Alternatives: On the web, a suitable pattern is View, Model, Template. A request to a URL is dispatched to a View. This View calls into the Model, performs manipulations and prepares data for output. The data is passed to a Template that is rendered an emitted as a response. ideally in web frameworks, the controller is hidden from view.

I like the View, Model, Template pattern suggestion, the separation of View (which data can be displayed) and Template (how it gets displayed) is an important one that I think too often gets lost in web application development.

If only the framework could be the entire controller all on its own though! Even the Ruby On Rails (the poster boy web application framework of the moment) cannot do everything unaided.  Writing controllers is not too bad if you are exposing RESTful resources - much custom controller logic is then reusable though things like authentication still intrude.  RPC oriented web appications are the ones that can really end up suffering from horrendously complex controller definitions.

The other main difference between Java/Struts1 and something like RoR is the considerable benefit gained by being able to define the controller completely within in the host language rather then having to resort to a code+XML definition.  I don’t think this should be underestimated. Personally I have always found the biggest impediment to grokking, testing and maintaining Java/Struts1 application code was the mixed Java/XML implementation, and the IDE support it almost demands when used in anger.

BTW, big contratulations to Bill on getting the APP spec (nearly) finished!

Monday, July 30th, 2007 atom, java, mvc, rails, ruby, struts

No comments yet.

Leave a comment

What I'm Doing...

  • Weird, Jeff Stelling (brilliant Sky Sports 'Gillette Soccer Saturday' anchor) is to be the new Countdown host. He might be good... 5 hrs ago
  • Merging Irish banks until only BOI & AIB exist is terrible idea. Their assets are too expensive to be 'saved' if required(>100% of I ... 9 hrs ago
  • I've got a ticket for the Pumas game tomorrow...can't wait! 12 hrs ago
  • @donncha OO now has a native OS X build of v3. Latest neooffice is still cut from OO v2 source still I think so it's probably a bit behind. 12 hrs ago
  • @EvertB Wondering if anyone 'in the know' could comment on status of irish mobile operator network capacity? 19 hrs ago
  • More updates...

Posting tweet...

Blogroll

LinkRoll

Recent Links:

Archives

Photos

ElectricPicnic08-1213

More Photos