About the Reviewer
Meera Subbarao has a Bachelors degree in Electronics and Communication Engineering and seventeen years of software programming experience around the globe, from Bangalore,India to Dubai,United Arab Emirates, to the United States. She has spent the past six years at DataSource, Inc. in Maryland and has been working on J2EE technologies exclusively for the last six years.  She is a Sun Certified Java Programmer as well as a Sun Certified Web Component Developer. Meera is also the Team Leader for the Javalobby/dzone book review team.
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.

Checking Java Programs



Author(s) Ian F. Darwin
Publisher O'Reilly
PubDate March 30th, 2007
Reviewer Meera Subbarao



One Minute Review


Positives
  • Covers PMD, FindBugs as well as Java PathFinder.
  • Provides screen shots where necessary.
  • Has reference links to all the tools mentioned.
  • With just 54 pages, the Short Cut keeps up to its name.
Negatives
  • Cannot be used as a reference book.
  • No mention of code coverage tools.


Sections

Intent & Audience

This Short Cut tells you about tools that will improve the quality of your Java code, using checking above and beyond what the standard tools do, including:

  • Using javac options, JUnit and assertions
  • Making your IDE work harder
  • Checking your source code with PMD
  • Checking your compiled code(.class files) with FindBugs
  • Checking your program's run-time behavior with Java PathFinder

Checking Java Programs is for developers who are proficient in Java. I encourage you to try at least some of these tools, like PMD, FindBugs etc; they are really valuable and can find real problems. Most of these tools are available as plugins for most IDE and it should be easy to integrate and run them.

Relevance of material

As per the publisher, Short Cuts are PDF documents that spotlight one specific topic, usually in fewer than 100 pages. Whether it's a first look at a brand new technology, a quick reference, or a thorough explanation of a narrow but crucial subject, Short Cuts bring you focused information in an easy-to-use, portable package.

This short cut doesn't focus on one tool. You will have to refer to other books or web sites for a detailed explanation or for getting a complete reference if you decide on using these technologies. There were some tools which I thought would have been worth mentioning like Cobertura, Emma for code coverage. I did send an email to the author and he said he liked the suggestion and would like to mention the same in the next version.

Chapter highlights  

  •   Provides step by step instructions to download and install the tools.
  •   In most cases shows how to use these tools with Eclipse.
  •   "Advice and Summary" boxes at the end of the PMD, FindBugs and Java PathFinder sections.

1. What It's Not About

This section is a very brief introduction to what this book is not about. The author mentions about the various open source tools. One paragraph did mention that the code examples were available online, but they weren't. As soon as I brought this up with the author, he did upload the files. Thanks Ian.

2. It Usually Begins with javac

In the first 2 paragraphs you will find details about how to use javac and add additional command line options. I had never used one of these, give it a try. The author gives us one such example using javac -Xlint:deprecation, unchecked will run the standard compiler with extra details on use of deprecated code and unchecked type conversions.
In the next 2 paragraphs of this section, the author mentions about JUnit tests and also on how to use Java's assert keyword. If you are already using JUnit tests you can as well skip this paragraph. Same goes with the paragraph which explains about the assert keyword.

3. Making Your IDE Work Harder

This section covers some useful tips for using Eclipse IDE. The author explains with screen shots how to enable useful warning, disable useless ones and also promote warnings to errors.If you are familiar with Eclipse, you won't find anything new in this section.

4. Source Code Checking with PMD

As per the web site, PMD scans Java source code and looks for potential problems like:

  • Possible bugs - empty try/catch/finally/switch statements
  • Dead code - unused local variables, parameters and private methods
  • Suboptimal code - wasteful String/StringBuffer usage
  • Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
  • Duplicate code - copied/pasted code means copied/pasted bugs

 The next 15 pages of this short cut are dedicated to PMD. This short cut covers most things you would actually need to know about PMD. The author first explains installing the plug-in for Eclipse, using PMD from the command line and also with Ant.            

In the next few pages you will get to know how to write project specific rules using either XPath as well as Java code. For example if you don't want any new Threads being created in your project, you would write a rule to catch the problem as soon as it enters your code. You'll also be able to modify PMD's prepackaged ruleset by overriding various rules properties.

5. Static (Class File) Checking with FindBugs™

FindBugs is a static analysis tool that examines your class or JAR files looking for potential problems by matching your bytecodes against a list of bug patterns. It was written at the University of Maryland. FindBugs was a completely new tool for me. I used the eclipse plug-in and found it very useful.This section has 16 pages and covers command line usage of FindBugs, the GUI which provides a reasonably nice user interface, using FindBugs with Ant and finally with the authors favorite IDE which is mine as well, FindBugs with Eclipse.

6. Dynamic Checking with NASA's Java PathFinder

According to the web site, Java PathFinder (JPF) is a system to verify executable Java bytecode programs. In its basic form, it is a Java Virtual Machine (JVM) that is used as an explicit state software model checker, systematically exploring all potential execution paths of a program to find violations of properties like deadlocks or unhandled exceptions. Unlike traditional debuggers, JPF reports the entire execution path that leads to a defect. JPF is especially well-suited to finding hard-to-test concurrency defects in multithreaded programs. The author shows how to build and run Java PathFinder from the Subversion repository. Next you will learn how to configure and extend PathFinder.

7. What's Next? 

This is the last paragraph in the Short cut in which the author concluded the book saying that "there is no single solution that will make you the world's best programmer. Believe me, if there were, I would have already told you about it. ..."

I completely agree with the author, there isn't a single or simple solution either.

Rating

This book is not intended to be used as a reference for any of the tools the author has covered like PMD, FindBugs or Java PathFinder. If you haven't used any of these tools, I would recommend you to buy this Short cut and try integrating them with your favorite IDE or even Ant build scripts. This Short Cut does help you in getting started quickly if you decide on using one of these tools.

On the other hand, if you are already using most of these tools, there isn't much additional information you will get from this book.

Relevance   
Readability
Overall  

Resources

Authors web site.

PMD Web Site.

FindBugs Web Site.

Java Path Finder Web Site.

Apache Ant Web Site.

JUnit Web Site.

Review of PMD at Javalobby.