Book Review: Java Extreme Programming Cookbook

Since I've been talking about Unit Testing quite a bit recently, I thought I'd offer up a review on a book I read a while back. I thought it was a solid roundup of both the principles and the tools used to support Extreme Programming in Java. Overall, I'd give it a 9/10 and I deduct a point solely due to the fact that since it details the usage of numerous Open Source projects, it's halflife could be very short. Regardless, this is more than enough to get you started and will teach you the basics to be able to do even more interesting things.

Just to make this clear right off the bat, if you're not working in Java, only pages 11-27 are going to be of any use. These pages go over the different pillars that make up Extreme Programming (XP). Whether you're using XP or not, you can pick and choose the pillars you need and customize them to your project pretty easily. The principles are: Pair Coding, Unit Testing, Refactoring, Iterative/Minimal Upfront Design, and Regular Builds. I have yet to see a project that cannot benefit from having Unit Testing and Regular Builds in place. These two items serve as a great safety net for current and future development efforts by detecting errors soon after insertion.

Anyway, when I picked this book up about 18 months ago, I was temporarily out of the Java world completely. At the time, I was stuck in the asp world - not even .Net - and I was chomping at the bit to start playing with and using these tools. I had worked with Ant a bit a few years back, but only had an inkling of the power and flexibility available before the project ended. This book blew my socks off. It was a huge crash course on Ant, jUnit, httpUnit, and some other things I haven't had a chance to use (Cactus, jUnitPerf, XDoclet).

The book starts with a quick and dirty overview of how to use Apache Ant. Ant - for those who aren't familiar with it - is a flexible cross-platform build script written in XML. All complaints about XML aside, it offers a very simple straightfoward way of having a single script run equally well on all development environments. Ant therefore serves as the foundation for everything else to build upon. It's distributed with later releases of Eclipse and is probably available with other IDE's as well. The .Net equivalent is nAnt.

The next major segment of the book is dedicated to jUnit. It covers how to write some basic testing structures, set up and tear down techniques and even gets a bit into naming conventions. I am a major advocate of Unit Testing and therefore write Tests to handle most calculations, string parsings, and similar things within my systems. I make a point of making sure the code works and breaks where expected. The easiest way is to test within, on, and just outside your boundary conditions along with any oddities that pop up as development proceeds. I Although I've never delved into it, jUnit seems to even support testing Swing code. The .Net equivalent is nUnit.

The final aspect that I'll cover is their discussion of httpUnit. The power of this one is pretty impressive all the way around. I have yet to implement this fully within a production environment, but the form submission and validation has a huge amount of appeal to it. I'm considering an implementation that will sit along side dotProject in order to validate modules and form elements. Just remember to build your pages using XHTML. Not only will it make them more testable for your purposes, but they are more readable for screen readers and other non-standard browsers. Now if there was just a way to validate Section 508 Compliance too...

Being one of O'Reilly's cookbooks, the book is filled with examples detailing precisely how to develop relatively small segments of code to do one specific thing. In addition, some sections build upon each other to demonstrate more advanced concepts.

If you are looking solely for a book on Extreme Programming, there are better. If you're looking to integrate some of these techniques into your Java projects, I highly recommend it as a great primer and intermediate reference guide.