Tuesday, September 29, 2009

Automated Quality Assurance and Robocode Ant Build

Ant and Ivy are a great combination to automate your build for distribution. Think of Ant as what Make is to C/C++, and think of Ivy as what FreeBSD Ports is to automated dependency resolution. The reason why Ant and Ivy are so popular is because of its simplicity and flexibility. Instead of downloading all packages manually and configuring the software, Ant and Ivy do this automatically which helps in accomplishing the Three Prime Directives of Open Source Software.

Quality Assurance is not an entirely fun task, so I used PMD, CheckStyle and FindBugs to aid in this process. Here is a quick overview of what these tools can help you accomplish:

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 bug

CheckStyle also scans Java source code and looks for style violations among various others.

FindBugs checks Java bytecode for known bugs. This static analysis tool can spot null pointers, problems with equals() and hashcode() implementations and many other issues that may have been overlooked.

While these tools should not replace a person doing line by line code analysis and review, it does help automate catching the low hanging fruit.

Along with creating a fully automated build that has been tested with junit test cases ready for you to download and run instantly, I have also improved FlankBot, my Robocode battle bot, to be more intelligent against Walls based robots. Some of the improvements are:

Conserving Energy (only shooting when close, only shoots if miss is below n)
Detection of Walls Bots ( 95% winning against sample Walls)

Download Flankbot with Robocode here.

0 comments:

Post a Comment