Monday, August 7th, 2006p>
Digg this review!
Christian Gross’ Ajax Patterns and Best Practices is a quality book for the intermediate to advanced ajax programmer who is looking to expand their skills. This is definitely not a beginner’s introduction to ajax, as once you get past the first three chapters or so Gross dives into some heavy duty patterns for difficult problems in ajax. The book suffers from a lack of editing and a few curious technical remarks, but overall it does a good job of covering ajax patterns and practices. Gross is obviously a fan of REST and XML, so your views on this book might depend upon how much you agree with his technical choices.
Chapters one and two cover the basics of the XHR object and using the factory pattern to abstract away browser differences for the object. Chapter three covers “Content Chunking”, Gross’ term for what he admits is core to ajax – an event leading to an asynchronous request with then responds with some sort of content to inject back into the document. Chapter four covers caching practices, and five covers the “permutations” pattern – ie separating the URL resource from the representation. Six covers “decoupled navigation” (ie seperating the event triggering/handling from the business logic they fire), seven covers switching between states seamlessly, and eight covers the even popular “persistent communication” (ie polling) pattern that many of you may have seen yesterday in coverage of the WWDC. Nine covers workflows in ajax with the “state navigation” pattern, ten is “infinite data” (see the scrollbar at live.com), and eleven covers treating remote services as the model in MVC via REST.
Regarding serialzation, Gross has this to say about XML vs everything else:
Many people might think that XML has its problems and have proposed protocols that are better. Frankly, I think that is plain wrong…Therefore, when writing your own Ajax and REST applications, stick to XML.
While I certainly see Gross’ point about the benefits of interoperability with web services when using XML, he fails to mention how sites like Yahoo and del.icio.us are offering their data in JSON. If your app will only ever talk to del.icio.us, for example, it might not be best to go with XML. There are also the cases where you have complete control over the services, for an intranet app for example, and you may go with JSON or YAML for developer friendliness. I think at least discussing serialization in the context of a simpler app that doesn’t talk to web services would have been helpful for developers who aren’t writing the next big XML mashup.
Besides that nitpick, this book will be great for someone who wants to know some of the big pitfalls of creating large scale ajax apps, and ways to sidestep them. The only other significant fault is the editing, with one too many awkward run-on-sentences. The overall tone is conversational and easy to follow once you get past that. The patterns covered are very useful, particularly the caching pattern and the different ways of handling transitioning and transforming state. Recommended, particularly if you are doing a lot work with REST/XML and multiple web services. If you can only own one Ajax book – get Ajax in Action – if you own two, make Ajax Patterns and Best Practices your second choice.
Posted by Rob Sanheim at 10:53 pm