Frameworked Up

I've been spending a lot of time discussing my new development framework with other web application developers, garnering their feedback and integrating it into a whole new design pattern that solves a lot of the problems associated with MVC.

Two of the main bottlenecks with any MVC framework are:

  • Memory bloat in the controller
  • IO operations on the view when rendering
One of the tenants of an MVC design is that your data gets loaded by a controller function and sits there until the view renders it as a page. These are usually a bunch of fairly-heavy state-aware active record objects. This is all fine in most cases, but if you're worried about memory utilization and performance you'll realize that it can quickly get out of hand.

What I've opted for, instead, is to develop a framework based on XML-RPC. Each URL represents an API end-point that returns pure XML. Since the objects aren't having to sit in memory for rendering later, they can be immediately removed upon spitting out its XML response. 

Since XML responses aren't particularly useful to humans, each response includes a reference to its XSL stylesheet. The XSL stylesheet allows the browser to take the data returned as XML and render it as a DOM view. Your users' web browser does all the heavy lifting and you bypass all those expensive string operations that most template libraries use. 

XSL is supported in every modern browser. However, with a simple .htaccess file you can instruct the server to render the XSL and the XML into an HTML document for any browser or search engine that doesn't natively support it. Win!

Prefer JSON-RPC/JSONP/REST? It supports pretty much anything you want. Currently, my standards compliance could use a little more tweaking to conform to spec, but it's well on its way to being a flexible API framework. Since every response is merely XML, it makes a great back-end to web applications using AJAX.

What's this all mean? Well, it means you write a back-end API once that's made seamlessly available over XML-REST/XML-RPC/JSON-RPC/JSON-REST/JSONP and have it all render down to HTML for people accessing it via a browser. Amazing!

For the sake of providing a demonstration, I'm giving a link here to a early technical proof-of-concept:
When you load up the main page it shows you a description of the classes available to make requests to.
You can click any class which opens its own description.
Any of the links in an class description represent a function within the class. 
The most easy one to see in use is the "update" function, as it will show you what an automatically generated form looks like and allow you to submit it to the database.
Because I used jQuery Mobile to create a simple UI, some requests are "forced" to load as XHTML so that they render correctly with its animated transitions. But, with some tweaking to the URL you can easily pull up the source and see that it's all just an XML response with a stylesheet attached.

Update: The Daily WTF posts a rebuttal