Friday, July 15, 2011

Is Ajax a spice or an entree?

A recent trip to visit a customer site had me thinking about food. No, it wasn’t the great big burrito I had for lunch. It was the use of technology in the application. We were invited to this customer site to examine a PHP application that was not performing well. This is not unusual for IBM i, Linux or Windows based PHP applications as no one is immune from challenges with coding practices and I for one can write bad code in more than 10 languages! Frequently, customers ask us a couple of standard questions like “where is the problem”. In many cases there isn’t just one problem but a handful of poor practices or as in this case some really good practices, poorly applied.

Now it is not unusual for PHP to “take it on the chin” for the sins of poorly applied technologies like Dojo, ExtJS and others. Frequently, we at Zend are in the trenches of a “This PHP application performs like $@#%” war and have to explain that the PHP is perfectly fine. In many cases the lack of indexes on SQL calls, tuning of the FastCGI or overuse of ajax can contribute to poor application performance. This is why the Application Audit from Zend becomes EXTREMELY valuable. Forgive me as I am not trying to turn this into an advertisement for our canned services as much as relating a recent experience.

After we finished the application audit, our auditor creates a summary. Sometimes in as few as 20 pages and others have shot well past 100. The length of the document really depends on what we find and the overall size and complexity of the application. Once the summary is completed we schedule a conference call with the auditor, customer and maybe a couple of carefully selected folks from Zend. For example, it would not be unusual to have someone from the ZF team join the call for a customer who is using ZF and needs direction on how best to optimize it. We went into the call for this customer with our punch list and I got to drive the discussion.

Like many of my discussions, I tend to think on the fly. The combination of ADD, diverse cultural experience and IT training gives me a unique ability pull analogies out of thin air. Some at Zend have referred to this as the “Pavlakian Response”. I was honored when they named it…I think. Regardless, I got on a bit of a roll with this customer as I started down a food analogy. Everybody can relate to food! We all have to eat, we’ve all had good meals and we’ve all had meals that left us a little less impressed. In this case, I chose to attack the application issues using the spicing analogy.

The meat and potatoes of most PHP applications are typically made up of the PHP code, HTML and database access. In most transaction based applications THIS IS ALL YOU NEED. Now stop with the torches and pitchforks regarding ZF, CSS, JavaScript, etc. I’m not saying those technologies are not valuable; in fact it is quite the contrary. I think JavaScript is EXTREMELY valuable and would encourage everyone to get educated. But just like with food, a balanced approach can make for an ideal experience. Different applications require different solutions much like food may differ based upon the environment. You simply cannot compare a buffet at a conference to a seven course meal at a fine steak house, yet I have enjoyed the experience of both.

Clearly this application was using JavaScript more like an entrée than as a spice and was causing significant problems with latency and unnecessary page rebuilds. For example, somewhere along the line they forgot that the A in ajax stands for asynchronous. Instead they were building everything serially, every time the page was built! This is nice for graphical applications or high level summaries where the data may not change very often. But in transaction processing you do not want to make the data entry folks wait for a summary element to be built before they can continue keying. As IBM i programmers we know this. As web designers become transaction based application developers, a little time in the kitchen working on how to make a balanced meal is in order!

These analogies come in handy because sometimes you never quite know who you are talking to on the phone. The audience for this call was very diverse as everyone on the phone understood what the application was supposed to do but each person possesses a very different level of technical expertise. While opening up the code might work for the developers in the room the business analysts and executives who may not have seen code in a few years might not appreciate the level of detail and potentially tune out. The food analogy helped all of the people in the room relate the fundamental issue and communicate at a common level. While nothing communicates value like a shared understanding we all can relate to a really good meal!

So, I ask you, are you using Ajax or other technologies as a spice or as an entrée?