Thursday, April 17, 2008

MVC is dead! Long live MVC!

It happens. A TLA (Three Letter Acronym) becomes popular for a time, but eventually, a new TLA rises up and overthrows the previous TLA ruler.

Just like with political leaders and revolutions. But as we all know, the more things change, the more they stay the same.

So the latest TLAs, among others, are RIA and SOA. These are, respectively, Rich Internet Application and Service Oriented Architecture.

What?

OK, an RIA is a web-based application that uses more than just your basic HTML (on the "front end"). Mostly, this means AJAX (ah, an FLA!). Which means more work is being done in your browser, thus speeding things up and making lots of visual flash more doable.

SOA just means a web-application that doesn't just spit out HTML (on the "back end"), but instead spits out some more easily parseable format like XML or JSON and is (hopefully) clearly documented. This lets multiple different other applications make use it, instead of just being displayed by one built in HTML gui.

So what am I getting at? You already know these things? Well, a recent article claimed that MVC was dead because of the advent of RIA-SOA. Model View Controler is a design pattern that goes all the way back to the days of Smalltalk in the 1970's. More recently is has become pretty standard in the design of web-applications.

In the typical implementation of MVC, the Model is generally a class that handles saving/loading information from a database. The View is another class that creates the HTML, and finally the Controler is what glues it all together.

So how does this contrast with RIA-SOA? Well lets see. The RIA part contains code to display HTML (the View), code to get/save information (the Model) which it does by consuming services provided by the SOA, and most likely some more code to handle the interaction (Controler) as you click on things. That's on the front end. On the back end, you have the code that loads and saves from a database (Model), spits back formatted data (View), and defines what you can do (Controler).

It seems to me that, really, RIA-SOA is just MVC-MVC. Yeah, its a higher level concept built on top of MVC because it takes what would normally just run on the back end, and splits it into two parts to put more of the work onto the front end. But to say it kills MVC is, really, kinda silly.

And you can't really simplify it to be M-VC, either. That is, you can't just implement all of the View and Controler on the front end and the Model on the back end. Why? Security, for one. You have to maintain all logic on the back end as well as the front end to prevent somebody doing something bad. Having the logic on the front end is, well, candy to make it look nice.

Now, all of this ignores the fact that the typical, modern implementation of MVC really is not at all what the inventor intended for it to be (see Naked Objects, particularly the forward by Trygve Reenskaug [yes, that is spelled correctly..]).

So, yes, in a way, MVC is dead, long live MVC...

No comments: