|    Home    |    Meetings    |    Wiki    |    Projects    |    Discuss    |    Reviews    |    Members    |   

Title: Java Extreme Programming Cookbook
Authors: Eric M. Burke and Brian M. Coyner.
Publisher: O'Reilly
Pages: 264 pages
Reviewer: Andy Bach
Synopsis: A good look at the application of "Extreme Programming" principals to java code testing (w/ JUnit, HttpUnit etc.), w/ overviews of some open source (OS) java project tools (Ant, JBoss, Tomcat).
Table of Contents 1. XP Tools 2. XP Overview 3. Ant 4. JUnit 5. HttpUnit 6. Mock Objects 7. Cactus 8. JUnitPerf 9. XDoclet 10. Tomcat and JBoss 11. Additional Topics

I should start off by saying I'm neither a great java programmer nor am I an "Extreme Programming" (XP) devotee, so I may not be in the book's intended audience. While I remain "unconverted" (XP folks sometimes make it seem like a religion), the book does give a good argument for the "test first, test often" methodology. Showing you the tools java has to make this easy is pretty much the book. As far as the 'cookbook' aspect - well, you'd probably "starve" if this was your only cookbook (compared to, say, "The Perl Cookbook" (which, at 3 times the size and a mere 5 bucks more, seems a much better deal)) - the recipies do not give you full chunks of working code but answer question like "You want to run Ant", "You want to provide help messages in your buildfiles", and "you want to write unit test for your Swing code." The material seem to have been forced into the cookbook format. You won't steal, er, use the books's code to build an app, but if you use the book, you will build a better project the next time you start an app.

That's one of the major points - XP starts before you code and it is almost as if the point is not to build an app, but to build the tests that show the app works. By constantly building the unit tests as you go, solving small problems one at a time and then making sure your test framework can handle them, the app will sort of arise from the middle of it all, ready to go. I simplify, but that's the step you need to take if you're going to be an XP programmer. Or, actually, one of a pair of XP programmers, another of the major XP beliefs is all programming is done in pairs, 2 people to one keyboard.

Chapter 3 was where things got going for me, I'd recently tangled w/ Ant (the OS build mgmt util for java) trying to get a java SOAP client to work. The client was easy, the installing of all the related jars took most of a night. CPAN it is not. The chapter does a great job of building up an Ant "build.xml" file from a basic template, to adding help messages, dependency checks, installing other programs etc. It would have been very helpful in my wrestling w/ the SOAP client build. It also starts the JUnit discussion. which continues into chapter 4. JUnit is the heart of Java Unit tests, its a way to wrap each snippet of code w/ a test procedure, embed it into a test framework ( a "test suite") so that, via Ant or an IDE, you can make a change, rerun the tests and be sure you've not broken anything. Adding new code, you build your tests in, so that, once you think you're done, all the tests can be rerun to ensure you didn't break anything and the new code does what you designed it for.

HttpUnit (Ch 5) is an OS java add-on that give something like LWP to java - its a framework for web access w/o the browser. You can fetch forms, query them for content, fill-in values and submit the results. Again the focus is on HttpUnit as part of the testing process. Whatever web app you're building, you need to test it, step by step, to be sure it does what you want. HttpUnit (www.httpunit.org) seems like an excellent addition for anybody using java and the web, It lets you do:

import com.meterware.httpunit.*;

...

  WebConversation  webConversation new WebConversation();
  WebRequest request = new GetMethodWebRequest("http://localhost:8080/news");
  WebResponse response = webConversation.getResponse(request);

This is not a book for java newbies, a lot of background is assumed and the example code is fairly high-level java. The one chapter I had higher hopes for was the Tomcat/JBoss.