Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Evaluation of Code Metrics

There has been a considerable amout of discussion about code metrics (e.g.: What is the fascination with code metrics?). I (as a software developer) am really interested in those metrics because I think that they can help one to write better code. At least they are helpful when it comes to finding areas of code that need some refactoring.

However, what I would like to know is the following. Are there some evaluations of those source code metrics that prove that they really do correlate with the bug-rate or the maintainability of a method. For example: Do methods with a very high cyclomatic-complexity really introduce more bugs than methods with a low complexity? Or do methods with a high difficulty level (Halstead) really need much more amount to maintain them than methods with a low one?

Maybe someone knows about some reliable research in this area.

Thanks a lot!

like image 388
zlajo Avatar asked Dec 03 '09 07:12

zlajo


3 Answers

Good question, no straight answer.

There are research papers available that show relations between, for example, cyclomatic complexity and bugs. The problem is that most research papers are not freely available.

I have found the following: http://www.pitt.edu/~ckemerer/CK%20research%20papers/CyclomaticComplexityDensity_GillKemerer91.pdf. Though it shows a relation between cyclomatic complexity and productivity. It has a few references to other papers however, and it is worth trying to google them.

like image 117
Razzie Avatar answered Nov 30 '22 00:11

Razzie


Here are some:

Object-oriented metrics that predict maintainability

A Quantitative Evaluation of Maintainability Enhancement by Refactoring

Predicting Maintainability with Object-Oriented Metrics - An Empirical Comparison

Investigating the Effect of Coupling Metrics on Fault Proneness in Object-Oriented Systems

The Confounding Effect of Class Size on the Validity of Object-Oriented Metrics

like image 45
kc2001 Avatar answered Nov 30 '22 02:11

kc2001


Have a look at this article from Microsoft research. In general I'm dubious of development wisdom coming out of Microsoft, but they do have the resources to be able to do long-term studies of large products. The referenced article talks about the correlation they've found between various metrics and project defect rate.

like image 42
Avdi Avatar answered Nov 30 '22 01:11

Avdi