I’m sure I’m not the first to suggest this, but here goes.
Ever since somebody first thought of applying the Model-View-Controller paradigm to the web, we’ve had this:
Obviously there are many issues to consider.Â First and foremost is making sure that rogue clients cannot do anything to the database they’re not supposed to.Â But that’s a manageable problem — Amazon S3 is a good example.Â Apps that run entirely in the client can even be made more secure than their server-based counterparts, because encryption can be implemented entirely in the client, so that the server never sees the unencrypted data.Â (Clipperz, an password-storage service, calls this a zero-knowledge web app.)
There are some interesting possibilities.Â For example, the entire application, including the current state of the model, can be downloaded as a single web page for off-line use.Â (Clipperz supports this.)Â Also, the same application could connect to multiple data sources.Â And as with any RESTful architecture, back-end scaling is relatively easy.
Update July 10, 2008: I’m always amazed when one of my posts show up on Reddit.Â Maybe it was the diagrams.Â In any case, thanks to everyone who sent in comments.Â A couple responses:
- Yes, in a sense I’ve described Ajax.Â But most Ajax-related code around the web these days is still in the “dynamic view” mode rather than the “client-side controller” mode.
- I like Sun’s MVC diagram in which the View takes an active role in rendering the model rather than being just a template.Â It’s actually quite similar to what I’m suggesting here.
- Some MVC frameworks, such as Ruby on Rails, insist that logic in the View is bad, but then they include all these Ajax view helpers, so it’s a bit of a mixed message.
- I’m not insisting that all business logic be implemented client-side.Â Rather, I’m assuming some kind of “smart” database, with a RESTful front-end, that’s capable of containing business logic.Â Back in the day, these were SQL stored procedures.Â Now it’s probably something like CouchDB.
Update August 7, 2008: This is an example of the code-on-demand style described in Roy Fielding’s REST thesis.Â Link from Joe Gregorio.