The Cost of Pair Programming
As you guys have known, Pair programming is one of most important best practice of Extreme Programming and other agile software approaches. It can reduce bug rate significantly, it also has positive impact on improvement of programming skill, but the cost of pair programming is, boss have to hire more programmers to work together. Due to the finance concern, very few boss and orgnization adopt pair programming as their best practice.
In fact, an variant of pair programming can be used in very LOW cost. Programmers can "pair programming" with code checking tools, instead of human being programmer. In other words, we can programming with "robot" programmer.
PMD is a powerful static code checker for Java language, I don't want give a long definition here, because Wiki has gave a clear one.
- Possible bugs - Empty try/catch/finally/switch blocks.
- Dead code - Unused local variables, parameters and private methods.
- Empty if/while statements.
- Overcomplicated expressions - Unnecessary if statements, for loops that could be while loops.
- Suboptimal code - Wasteful String/StringBuffer usage.
- Classes with high Cyclomatic Complexity measurements.
- Duplicate code - Copied/pasted code can mean copied/pasted bugs, and decreases maintainability.
As mentioned in last sector, PMD is a static code checker can detect potential program in java source code. There are lots of similar tools in open source community, but PMD has its own competitive advantage.
- Easy to Get
- Easy to Use
- Document and support
findbugs (http://findbugs.sourceforge.net/) is an alternative powerful static check tools, if you don't like PMD.
PMD has provide plug-in for eclipse. It help you to detect and fix potential issues in workspace with GUI support.
This page give a brief but clear instruction on installing of eclipse plugins.
Once you complete the installation, you can check your code with context menu of PMD plugin.
1. Switch to PMD perspective
2. Select a java file you want to check
2. Right click mouse, select PMD->Check code with PMD.
PMD list violations in both outline window and Text editing box if it found some violations in your source code. Violations be assigned different level, some of them are critical while others are not. Usually we should focus on at least critical issues.
PMD can support us to find potential problems, bad practices and methods that has too much complexity. Programming skill of programmer also can be improved with PMD because programmers can know what bad practice is. In general, PMD can help software team to reduce defect rate and improve productivity.