Saturday, October 10, 2009

A Criticism of Ajax

Now please don't get me wrong I am all for Ajax if the requirements need it. However lately some things have made me wonder when to use Ajax and when not to....

Some times things just annoy me the way semi technical people come up with design decisions.
Some time back I had been working a very capable requirements analysis and he promised Ajax on pritty much every page the client had. I was a part of these discussions and I had a word with him offline why have Ajax for a bunch of simple forms in which a user will enter Fret data.

You may be surprised or shocked, his answer was in 2008 you can't build 1998 style web site. Come on dude thats no answer. Ajax costs more in development, testing and implementation. Getting it working across browsers is fun in itself and your clients don't want it.

Using Ajax for the cool factor is just not right. I have come up with some guidelines around when to choose ajax and when not to.

When not to choose Ajax
1. Because it sounds cool.
2. Because every one else does it.
3. Because you want to avoid the page refresh.

When to choose Ajax
1. When some of your controls get loaded based on user choices in other controls and the data is just huge to be cached on client side, for example on choice of a country you display cities and on choice of cities you display zip (pin) code
2. When you know you can write good java scripts (and java scripts are different from the DOM of the browser)
3. When the cost of getting all the data on start of the page is higher.

DONT APPLY AJAX ON THE ENTIRE PAGE.

Please note Ajax degrades server performance

I am glad I have said that, guys we should remember technology is present to solve business problems not for the cool or sales factor. Clients value honesty.

2 comments:

  1. You have addressed all the stakeholders. People forget that software is build to solve problems and hence should provide value to the customer. Technology will always evolve, choosing what suits best and keeping in mind effort and cost is what service providers should focus on.

    ReplyDelete
  2. I am not sure of one of your lines "Ajax Degrades server performance".

    But still thought that somehow this line is quite incomplete or irrelevant for atleast few cases.
    You cannot held ajax for poor performance.It all comes down to "how you design it".

    For some non tehnical people AJAX is Not "Asynchronous Java and XML" but just a fully connected medium like a window application. Architects and designers can get smart here and provide them that feel with alternative asynchronous methodologies.

    Also, Architects and designers should take some good time out when it comes to designing server and client side interactions in the application. More often LLD or UI Design misses it altogether.

    Ajax in .NET is doesn't end with Update Panels. There are better ways which exists.

    Lately I worked on a weather forecasting application which involved use of maps and complex overlays .
    I found a good feature in script managers which offers PageMethods , although this is part of Microsoft Ajax functionality, I would not call this is pure AJAX since response in no way is XML. In most cases I used JSON.
    But then the end product was no less than a google earth . :)

    Looking forward for your inputs and other design tips. Keep blogging

    Regards,
    Kunal Uppal

    ReplyDelete