The HTTP Pattern
I just got finished reading an article over at Ajaxian (great blog) about The Ajax Head Pattern; Unobtrusive Rails App. And had a few comments of my own.
While working at Kinetic, especially on our home brew stuff, I’ve made it a point to engineer our applications using what I call “The HTTP Pattern”.
Sound silly? It is meant to be, because HTTP serves us all we need for a great majority of the problem solving we do for our client’s systems.
Unobtrusive Javascript, Graceful Degrading, the separation of Presentation, Behavior and Structure, Microformats… all are just the basis of the W3C’s web.
Yet they serve us a model for keeping things simple and layering on additional tweaks and user interface enhancements. While giving us an architectural “golden path” to compliance for varying user agents.
That’s why I’ve adopted so much of their nuances into the systems I architect.
”...and what about Rails?”
REST with Rails (and more so Merb) takes us back down to HTTP, and allows us to utilize the loving goodness we have all veered away from (as an industry). REST has given us a wonderful platform to base our problem solving skills on top of. By utilizing the HTTP protocol, W3C standards and a bag full of common web usage gained from user experiences.
“Give us some examples”
Want to update your clients on various responses to requests they are sending? Of course we should be using “HEAD” and our HTTP status codes.
Want to persist a products hidden boolean value in the database when your clients click a check box? Of course we should degrade that back to a simple web form for users without XHR.
How about re-calculating a shopping cart in the navigation bar when a user chooses to purchase something? Request cart data as JSON from your back-end server and update your cart views on the return solely on the client-side (DON’T send view partial back to the client, ick!). If not present a simple web form and POST this data back.
All of these things are cheap, because thats the way they should work.
“Its always the simplest things”
Thinking simpler is what all of these patterns are based off of. Its the right time to be thinking about how you can utilize the web properly, before we add yet another layer on top of it.
