Friday, May 13, 2011

Rigor Automation

When it come software engineering, rigor refers to keeping the code healthy. Code health can be measured in terms of number of parameters, freeness from bugs and vulnerabilities, adherence to coding standards, unit test coverage being few of them. Now, 'rigor automation' refers to the automation of the process of identifying the deviations from this healthy status.

Programmers' lives have been made easy (or one may say hard), with loads of tools that have been built to automate the rigor. Standalone tools as well as plugins to various IDEs, especially eclipse, are there for this cause.

To measure the adherence to the coding style, eclipse plugin, CheckStyle is the most favorite choice. While PMD can also be used for this purpose, it can also be used to detect the potential bugs and vulnerabilities in the code. FindBugs is another great tool that finds bugs as its name suggests. Copy Paste Detector (CPD) does what it’s supposed to do, and it's quite important to find the copy-paste instances as most of the time they are indications of bad OOP design. So you better reconsider your class hierarchy if you have to copy and paste your code in number of places.

Cyclic dependencies between packages are also an indication of bad overall design. JDepend is there to save you by automatically analyzing the dependencies for each and every package to detect the cycles. It's also important to know the statistic about your code. The average, minimum and maximum length of you files, methods etc, the total LOC of you project, comment ratio provides invaluable insights to your code. Tools such as Metrics, SourceMonitor can be used to measure those metrics. Unit test is a must for healthy code and unit test coverage is the measure that provides the assurance in terms of robustness. Coverlicpse and Emma are two great tools that provide unit test coverage statistics.

While most of those listed above are for Java, a number of tools are there for other languages as well. What made me write this post is somewhat related to, me discovering another great tool. While I was looking for a tool that would help me adhere to PEAR coding standards which is used by phpMyAdmin, I found CodeSniffer. Since this post is getting elongated I will write a separate post about my experience with CodeSniffer. 

No comments:

Post a Comment