Agile Ajax

Review of Practical Ajax Projects with Java Technology

pract_ajax.gif At a quiet time during my 40th birthday extravaganza, I finally had the chance to finish reading Practical Ajax Projects with Java Technology by Frank Zammetti from Apress. I've read enough good, hands-on Apress books by now to get a warm and fuzzy feeling anytime I see their distinctive bumble bee black and yellow covers, so I came to this volume hoping to find an Ajax treatment in that mold. The result isn't an unqualified success in that regard -- it goes broad rather than deep -- but if you're an experienced Java developer looking to get caught up on some of the Ajax developments of the last year and a half, this book is for you.

The book assumes a good foundation in server-side Java development, but little or no experience with the technologies that make up Ajax. Part 1 of the book, which is comprised of Chapters 1-3, is an excellent review of Ajax technology and architecture along with a basic review of Java webapp development. Part 2 consists of seven chapters, each of which develops an Ajax application.

  • Chapter 1 gives a good overview of Ajax and the paradigm shift in web development that has caused. It also prompts the reader to consider questions such as when, where and why to use Ajax, as well as considering when fat clients or Flash are more appropriate for a Rich Internet Application (RIA).
  • Chapter 2 is a crash course on Javascript, DOM, CSS and XML. You'll see some variation on this chapter in most beginning Ajax books, but this one does a better job than most. There are a few technical nits I have, mostly with inheritance. Specifically, the code in the book MySubclass.prototype = MySuperclass.prototype should really be something like MySubclass.prototype = new MySuperclass() so that modifications to the subclass's prototype don't affect the superclass. Otherwise, both the superclass and subclass inherit from the same prototype and are siblings rather than parent-child. But beyond this small technical oversight, the chapter is quite strong.
  • Chapter 3 is a review of Java web application development using open source technologies, specifically ant, Tomcat, JSP's, Servlets and Jakarta Digester. If you're already familiar with Java webapp development, you can safely skip this chapter. The one exception to this condition is if you've only worked with commercial application servers and just need a quick kickstart on the open source tools.

As we said previously, part 2 consists of seven chapters, each of which develops an Ajax application. Each application makes use of a different Ajax framework or toolkit, so the treatment of each is not particularly deep. One other curious thing about the examples is that the last two don't make use of frameworks while the first five do. This seems a bit backwards to me, since frameworks provide a level of abstraction over the underlying technology which hides its workings. As a result, you end up not understanding the why and how of how it works. I would have started with simpler projects in the first two chapters that made no use of frameworks, going on to higher level of abstraction as we moved along.

  • Chapter 4 is a type-ahead suggestion application ala Google Suggest, i.e. you type in a few letters and it brings in a selectable list of possible completion. The example makes use of AjaxTags, part of the Java Web Parts (JWP) tag library. If you want to quickly add in Ajax to an existing application that incorporates JSP, this is one way, although after looking at all of the the different configuration and other files you have to write or modify (web.xml, ajax_config.xml, jsp, javascript, java), you might not think it's so easy.
  • Chapter 5 demonstrates the use of Direct Web Remoting (DWR) for developing a POP3 web email client. Most of the language in the chapter is taken up with development and explanation of the Javascript code that makes the application tick.
  • Chapter 6 develops an RSS reader using the Ajax tags from Java Web Parts (JWP) and the ROME RSS parser library. Among other things, this example illustrates how to deal with cross browser security restrictions, i.e. how do you grab RSS feeds and content from third party sites.
  • Chapter 7 develops an image manipulation and sharing application called PhotoShare using Dojo! and the JWP tags. Dojo is truly huge in its scope and this chapter focuses on just two packages: Events and I/O. This app definitely has the most wow factor of the bunch. There's something about manipulating and sharing images that makes you say, "you can't do that with a webapp."
  • Chapter 8 develops the first application in the book to make use of a database. The example program is an organizer and makes use of Prototype, WebWork, Spring and hsqldb.
  • Chapter 9 implements a chat application based on Struts and custom Javascript code not based on any library. This might have made a good chapter 2 application, since we get to go a little deeper into the practical workings of Ajax. It also illustrates the technique of "pushing" updates to the browser via periodic polling of the server.
  • Chapter 10 is also "naked" Ajax, i.e. no toolkit or framework. It is a rather fun little game in the style of Zork called Ajax Warrior. This is the first time we get to see JSON. The application also kicks the handling of XML, both on the client and server side, up by several notches. This is the most complex application and illustrates some strategies for implementing a complex flow. Ironically, this application is probably the easiest to understand because it makes no used of Ajax/Javascript libraries and could have made for a good Chapter 3.

Throughout the book, DTO, DAO and other classic Java webapp patterns are used and extended to work with Ajax and client-side Javascript. For those who haven't used Spring or some of the other open source Java libraries demonstrated in these applications, there is even some non-Ajax learning involved. Zammetti's writing is clear and to the point and his humor doesn't get in the way of reader understanding.

My main issue with the book -- a lack of depth -- is really more a problem with Ajax itself and the proliferation of frameworks. In truth, despite its depth, the book barely scratches the surface of what's out there now in terms of frameworks. The great pace of development means that since this book was put to bed, probably in the third quarter of 2006, several of the frameworks used in the chapters, such as Dojo and Prototype, have seen one or more releases. Still, this is a problem any Ajax book that references frameworks will have to deal with. Despite these shortcomings, I recommend this book to any Java developer who is looking to "learn by doing" with Ajax.



Technorati : , ,

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com