The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Monday, April 6, 2009

Code Smell

Ever heard of the term 'Code Smell'? Well it is a way to describe code in need of improvement.
So, to improve code you may need in times the measures to find the code which needs improvement. And for that there is a requirement of some tools and methodology to analyze code.

One such measure is called Cyclomatic Complexity. This is a measure of different control flows in a method in your java code or any other programming language method or procedure. It is counted as simple as number of if -else flows.. Its indicated that if a method has cyclomatic complexity of 10 or higher then it is considered to be a candidate for looking for defects.

One improtant derivation from cyclomatic complexity is you should have equal number of test cases to the cyclomatic complexity. I found a brilliant article on the same here

No comments: