Friday, February 17, 2006

Moving the view away from the controller

One of the most widely used embodiments of MVC architecture is the web application. Finding its most widespread origin in the desktop application framework, modern enterprise MVC applications live and breathe the Internet and the browser.

One result, however, is that the model, controller and viewer are usually colocated: the browser may display the web pages and let the user send input back, but it is in the server pages that the real code for the viewer runs. This is changing, perhaps.

New AJAX technologies are pushing some of the work of the viewer into the browser. One result is that whereas with Web 1.0 the viewer and controller run in situ on the server and developers must take care not to mix them, with Web 2.0 the joys of RPC appear and AJAX writers should bunch up requests for good performance. (Although seeing the responsiveness of Google's AJAX application, I wonder how much larger, faster bandwidth alleviates this problem.)

What I would like to try is this: in addition to enrichening the browser with AJAX, I would like to explore using Java WebStart for full-blown desktop applications while keeping the model and all or a portion of the controller back on the server.

Perhaps with SOAP, or simple XML-RPC, or even with extensions of HTTP (the path followed by WebDAV) the desktop application can call back to the server for work in the domain, model and persistence layers, while keeping a rich presentation layer local.

Thinking more about this, I can see the split between viewer and controller shifting under this circumstance. Say one had a tabbed application interface. Changing tabs with a Web 1.0 application involves trips to the controller to redirect the view. But changing tabs with a desktop application require no such direction. The initial view of the tab, though, would need the model on the server.

By no longer colocating all the MVC pieces, the relation or balance of power among them changes in, I believe, new and interesting ways. It is another option in the new Web 2.0.

Post a Comment