mvc

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

What I'm Doing...

  • Smartest Guys in the Room (the Enron documentary) is astonishing. I wonder if there are more Enrons out there (outside banking that is!) 10 hrs ago
  • @paulca if the service and your id provider both support the OpenID Simple Registration Extension then it should work - http://url.ie/r4y 4 days ago
  • @paulca I've been to the recent meetups, good couchdb talk btw, will be at the next one too. Not yet taken getexceptional for a real spin... 4 days ago
  • @topgold Try Nassau St (3rd or 4th bus stop down) or outside Budget Travel on O'Connell St, routes 46*, 10*, 145)... 4 days ago
  • @desdublin Des, save yourself! I'll go for some pints+nosh with you! Or else promise to drive wherever you were jogging to! 5 days ago
  • More updates...

Posting tweet...

Blogroll

LinkRoll

Recent Links:

Archives

Photos

ElectricPicnic08-1213

More Photos