Theocacao
Leopard
Design Element
Comment on "Separation of Model and View Web Frameworks"
by Andre — Aug 05
Apache Cocoon has a very interesting set of patterns for web applications. It's written in java but you don't have to write any java if your model is just database access (CRUD). Cocoon is basically the swiss-army knife of XML publishing.

First, you make your view in XML/XSLT/Ajax library du jour. A sitemap file is used to wire patterns of your URL space to what you want to show, which allows a very high level of creativity.

Then the model: it can be simply querying data from a DB (use Database Actions or the SQLTransformer) or it can be accessing a WebApplication (in my case accessing session beans in my JBoss server).

To glue it all together: the controller. In cocoon, this is flowscript: server-side javascript allowing to write the app like a normal desktop app instead of a patchwork of scripts cobbled together in a finite state machine. The developers basically added continuations to Rhino to do things like sendPageAndWait(), which freeze-dries the program until the user answers.

This is very flexible as you're not tied to one way of doing things (though this comes at the cost of a high abstraction and the resulting higher learning curve). The combination of Flowscript and something like SproutCore lets you organize your model-view interaction in many different ways, depending on the constraints you may have for each part of your app (reactivity, security, etc).

Yes there are still several environments involved but they bridge nicely: from the client-side JavaScript to the sever-side JS, JSON is your friend. From the server-side JS to the back-end Java app, any Java object can be used straight within your JS so it's transparent.
Back to "Separation of Model and View Web Frameworks"
Design Element

Copyright © Scott Stevenson 2004-2015