Tuesday, December 11, 2007

Book Review: Adding Ajax

Adding Ajax by Shelley Powers takes a unique approach to its discussion of Ajax in that it focuses on techniques for adding Ajax capabilities to existing web sites or applications. This is a useful perspective, since there are loads of sites and apps out there that can benefit from usability or esthetic improvements enabled by Ajax.

The first chapter of the book lays the groundwork for the projects and examples later on.  The book introduces the technologies we now commonly refer to as Ajax including its origins as a single proprietary extension to Microsoft Internet Explorer.  Early on, it also discusses the merits of "starting clean" prior to attempting to introduce Ajax to an existing site (or any site for that matter).  "Starting clean" in this context refers to use of CSS and well-formed XHTML rather than HTML tables and invalid HTML, of which many sites are guilty.  The point here is that Ajax applications commonly manipulate page contents via CSS and DOM, which may not work reliably unless the content is properly structured and styled.  This is good advice, regardless.

Following the background discussions, the book dives into a simple example web app illustrating the basic steps and issues involved in "Ajaxifying" an application.  Although the example is simple (a cocktail recipe viewing application), it actually provides a pretty good glimpse into the things one needs to think about and deal with when working with Ajax.  Next is a chapter focusing on a number of available Ajax/JavaScript frameworks such as Prototype, Dojo, script.aculo.us, Rico and others.  The discussion of the frameworks provide examples of their use built upon the cocktail example. 

The next six chapters each discuss a particular type of functionality one might want to add using Ajax and provide examples of doing so.  Specifically, visual effects, different ui structures (accordion, tabs), dynamic data (in-place editing, validation, etc.), paging (and a discussion of issues around navigation and history), advanced visual effects such as SVG and the Canvas object, and implementing mashup sites.

Examples are provided for each of the concepts as they are discussed, mostly building upon previous examples.  Server-side elements of the examples are largely implemented as PHP pages.  The client  side  Ajax portions are demonstrated using either the author's custom JavaScript/CSS/(X)HTML or one of the discussed Ajax toolkits.  As the book progresses, reusable portions of the custom bits are incorporated into a bit of a
framework that is used in multiple places throughout the book.  In my opinion, the author seems to somewhat shy away from the use of Ajax frameworks in favour of using custom-code, at least for simpler scenarios.  This may be appropriate, but it's a bit of a slippery slope and can lead to "reinventing the wheel".

My overall impression of the book is fairly positive.  I did find myself skipping  large sections of it as I was going through it, as this type of book isn't the best "cover to cover reading", especially since there are some pretty large code listings.  Also, as a Java developer, this would not be the first book I would buy if I were working with Ajax and Java.  While many of the client-side discussions are still relevant, the server-side techniques and examples are of comparatively less value.  There is a least another book  needed to get one's head around the range of Java toolkits for dealing with Ajax on the server side.  Some of the implementation techniques used in the examples would not be advisable for enterprise applications, or for those concerned with elegant software architecture.  I can forgive these points, however, since they are not the focus of the book.  I anticipate referring to this book now and again when I am looking for techniques to enhance an existing application's interface with some Ajax bling without affecting the underlying infrastructure.

Blogged with Flock

No comments:

About the wombat

Victoria, BC, Canada
This is our travel blog for our summer 2010 trip to France and the UK.