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/


  • 0
    点赞
  • 0
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
评论

打赏作者

AutoAsm

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值