(via my java.net blog)

This is a long blog entry … you have been warned.

Big conferences like JavaOne are always accompanied by the introduction of new books. This time’s no exception.

I stopped by the JDOCentral booth to visit my friend Patrick Linskey of SolarMetric, and he surprised me with a free copy of Bitter EJB, the new book he wrote with Bruce Tate, Mike Clark, and Bob Lee. I’m very pleased to have it, because early glimpses of some chapters have been posted on The Server Side, and it looks even better than Bruce’s original Bitter Java.

With apologies to Patrick, the first chapter I turned to was Mike Clark’s “Bitter Tunes,” about performance tuning for EJBs. Mike and I have an interesting history. Last year I gave a talk at JavaOne called “Stalking Your Shadow: Adventures in Garbage Collection Optimization,” and about two months later I gave the same talk at a No Fluff, Just Stuff symposium in Dallas. The talk may sound extremely technical and arcane, but it’s actually a “stealth agile” talk, in which I use the complexity of GC interaction and optimization to advocate a tightly iterative approach to optimizationavoiding both premature and “way too late” optimization by developing iteratively and building performance testing into your development process.

In the talk, I recommend using a package called JUnitPerf to automate performance testing and integrate it into your build and test process. In Dallas, I got to that slide and heard “Thanks! I’ll pay you later” from the back of the room. That’s how I met Mike Clark, the author of JUnitPerf. And I’m glad I did, because he’s one of my favorite folks in the industry.

Mike and I independently began delivering the same message: although the hazards of premature optimization are well known, it’s also possibleeasy, in factto wait too long, and only learn about performance issues at a stage when they’re so deeply embedded in your architecture that it’s all but impossible to eliminate them. JUnitPerf is designed to help with that, making automated performance testing an easy and repeatable task, so that you can find performance problems as soon as they appear and deal with them before it’s too late.

The first antipattern in Mike’s “Bitter Tunes” chapter is “Premature Optimization” (and rightly so, because many developers still need to hear that message). But the solution to premature optimization isn’t to just wait ‘til the end of the project; it’s to wait until you see real performance problems, and then attack them as soon as possible. So the second of Mike’s antipatterns is “Performance Afterthoughts,” and the solution is “Plan Early and Often” (a title I really like). Mike’s advice applies not just to EJB projects, but to all software projects.

I’ve focused here on one chapter of Bitter EJB, but from what I’ve seen, the rest of the book is just as great, and our industry has needed a book like this for quite a while now. You owe it to yourself to buy a copy.