Pair Programming with PMD

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.

What's PMD

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.

PMD is a static ruleset based Java source code analyzer that identifies potential problems like:

  • 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.

Why PMD

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
  • Powerful
  • Customizable
  • Document and support

findbugs (http://findbugs.sourceforge.net/) is an alternative powerful static check tools, if you don't like PMD.

How to use 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.

http://pmd.sourceforge.net/eclipse/

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.

Conclusion

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.

References

1. http://en.wikipedia.org/wiki/Pair_programming

2. http://en.wikipedia.org/wiki/Extreme_Programming

3. http://pmd.sourceforge.net/

4. http://findbugs.sourceforge.net/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值