« In my mind I'm gone to... um, the other Carolina | Main| Create, edit and delete without agents »

The right tool in the wrong hands

Category rants
When I first heard about AJAX, I instantly loved the idea because of the context in which it was presented: an approach for sending the server only what it needs to know in order to tell the browser only what it needs to know. Ever since, I've heard numerous tales of AJAX being used inappropriately - mostly as an excuse for the developer in question to "look cool" by using it. Honestly, I wish whoever originally coined the term "Web 2.0" hadn't; that's just an invitation for folks to attempt to prove they're on the cutting edge. But this stuff isn't particularly new, it's just being used in new ways, and like all tools, in the wrong hands it can spell disaster. Even JSON isn't new... it just has an acronym now, so suddenly we're all discovering what's been there all along, lying dormant.

Several folks have linked to the latest WTF as an example of AJAX gone ridiculously wrong. I've even seen some chatter lately discouraging any use of AJAX because it creates a burden on servers and networks. But I feel inclined to point out that appropriate use of it isn't. Consider as an example of an appropriate use the default behavior of Domino combo boxes that use the auto-refresh option. Left to its own devices, the default implementation not only triggers a page refresh, but also causes the entire form to be submitted to the server. On a very basic form, that's no problem. But if the form is rather lengthy, and the first two fields are drop-downs - the second of which depends on the value of the first to determine its selectable values - AJAX would provide a much more responsible approach (especially if it's using JSON, not wrapping everything in XML tags); send only the value of the field that changed, return only the values that should now be selectable in the next field. In this scenario, the server gets involved as often as it would have anyway, but less data is exchanged.

Even in the case of a basic form, AJAX is occasionally more respectful of bandwidth than the alternative... and that's when the site design is complex and/or busy. If the form itself is surrounded by top navigation, left navigation, footer information, a couple right sidebars, and some graphics (oh, say, for example...... this site), why bother asking the entire page to be downloaded again (yes, I know, there's a little thng called a cache, which saves so much bandwidth... unless of course your users decide to disable theirs) when you could just send a few bytes of data and get a few back?

So please, those of you that use this tool to feel (and, yes, appear) cutting edge, consider whether its use is actually appropriate before doing so. Otherwise, others who are genuinely trying to improve user experience and conserve system resources may soon encounter a fair amount of resistance during code reviews.

Comments

Gravatar Image1 - Zoiks. The other day I mentioned to my new boss that I'd made a minor change to an application, and was hoping to get that change pushed to prod. He asked, "Which design elements did you modify?" "This one," I replied, and pointed to the form that was still highlighted in my Designer client. He walked next door to his office, and was gone two minutes before I heard, "Okay, it's live." So apparently that's our process. Requires a fair amount of trust, and I imagine if I were to violate that trust, I'd have to earn it back. But at the moment it's a rather efficient approach.

Gravatar Image2 - No - we aren't going live till the end of August - and that's only if all the planets line up.
AB changed our process - it now takes 70 (not exagerrating) steps to go from INFO ticket to production - with no less than 2 different triage processes along the way. You are missing the good stuff here.
How'd your move go? WE MISS YOU

Gravatar Image3 - Agreed; setting RestrictToCategory this way can be quite handy. Trouble is, depending on how many records are likely to be returned, actually pulling the view content when a new category is selected can mean a large chunk of data is transferred... but this is another perfect example of where it makes sense to do this via AJAX instead of the default categorized view behavior. Normally, clicking a twistie (or replacement graphic) would trigger a page refresh and cause the entire page layout to be sent to the browser again. But if it's AJAXified, only the expanded category's contents are pulled, so there's actually less data transferred than usual. Particularly if the response is formatted as JSON... rather than letting Domino send all the formatting info, we can just eval the category contents as an object, then update the DOM to display the content the way it ought. So, again, less load on the server, less load on the network, more load on the browser. Another example of where AJAX is actually conserving resources, not wasting them.

Vince DiMascio has an example of using this approach quite well:
http://www.vincedimascio.com/vince/vpd.nsf/all/93CFF6FC0D84042388257190007690E0

The primary intent was to demonstrate integration between Google Maps and Domino, but it is also an elegant demonstration of how JSON allows view data to be easily resorted and recategorized on the fly.

Gravatar Image4 - I have used a bit of ajax on my site and other applications that I have built. It definitely has it's place in the online application world, but does require the designer to modify his/her way of thinking. I find it especially useful for single category views use a selection box to determine which category to show.

Sean---

Gravatar Image5 - Code reviews are for wussies - wussy!

Gravatar Image6 - Which reminds me, Dan, y'all gone live yet? Or would that be an extra special move request?

Gravatar Image7 - What a foreign concept. Effficiency. Unfortunately thats not part of our process.

Contact Me

Hire Me

Elsewhere

What the Quote?

"Let me just ask you this so I can go cause more wanton destruction."

Alex Belt

"'Cause by then we'll just think what we want to do, and we'll see it in our goggles."

Laura Tripcony

"NSD? What is that, some kind of protein shake?"

Steven Rodgers

"I was talking to your boss last night, and he told me, 'I have some really bright people... I'm just not so sure that they're sane'."

Mary Beth Raven

"You look a little different now, but you still smell the same."

Kathy Tripcony

Apparel

Lotus Rocks

I write the code that makes the young girls cry

Current Terror Alert Level

Assorted Linkage

ClustrMap