When should you use Ajax? Whenever you want to create a rich client application with the universal reach of the Internet. Stuart Halloway, speaking Friday afternoon at this fall’s Northern Virginia Software Symposium, predicts Ajax will be part of nearly all web applications within the next year. Stuart’s first session of the day focused on the architectural issues involving Ajax, from technical features to selling Ajax to management. In 90 minutes he discussed:
- the reasons to use Ajax
- how to introduce Ajax at your company
- the resistance you’ll encounter when you do
- the tools and libraries to use in Ajax development
- the architectural decisions you’ll need to make
- how Ajax isn’t a panacea for all applications
Jesse James Garrett
Jesse James Garrett to hide browser differences behind an adaptive interface provided by a library like Prototype or Dojo. Garrett coined the term Ajax in his seminal paper, “Ajax: A New Approach to Web Applications.” Of course, it also helps, Stuart added, that the functionality provided by Internet Explorer and Firefox have converged over the years.
The reason to use Ajax in your web applications is to create a better experience for your users. Ajax allows your web page to communicate to the server in order to update the page “behind the user’s back,” making the application more responsive to the user’s actions without having to reload the page.
- Firefox Consider the Firefox browser (with its extensions that follow) your development platform and Internet Explorer as your deployment platform, Stuart said.
- Tamper Data a Firefox add-on that logs all web navigation. It not only allows you to see what requests and responses are traveling between the Ajax components and the server, but it allows you to modify them or completely stop the request and see how the application reacts.
A survey at an Ajaxian conference showed that more than half of the Ajax developers were using Prototype, Stuart said. Most of the rest were using Scriptaculous (next). Prototype allows you to register multiple event handlers to events (
Ajax.Requestfunction that works as a factory to return the appropriate function that works with the user’s browser version.
A library built on Prototype to provide page effects (highlight, fade), drag and drop, auto-complete and other features.
This is a heavy-weight “kitchen sink” library, Stuart said, that provides almost everything you need for an Ajax application.
Introducing Ajax into an application raises two key architectural questions, Stuart said. These are the questions to think about early and thoroughly because changing the answers later could undermine previous development work.
Dojo is the library beloved by Java programmers, Stuart said. It’s bigger than all the other libraries, but it does more. Its API provides fixes for Back-button issues, client-side data storage, and other features. Stuart dislikes Google Web Toolkit. “I think it’s architecturally wrong,” he said, but I think I zoned out when he described the reasons for his dislike.
Although Ajax is useful, it won’t be a panacea for all applications, Stuart said. Learning to design with Ajax correctly will involve some of the same growing pains the development community learned in creating n-tier applications. Stuart likened the future growing pains in the Ajax world to the pains Java programmers suffered in implementing n-tier web applications using EJB. “We’re going to make a ton of mistakes” implementing Ajax applications, he said. “Asynchronous is hard. Asynchronous is as hard as threads, except you don’t have an API in front of you reminding you how hard it is.”