BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Measuring the Immeasurable: Code Metrics for Visual Studio

Measuring the Immeasurable: Code Metrics for Visual Studio

Code metrics are a way to mathematically calculate the complexity of code. There are several ways to do this, 5 of which are included in Visual Studio Orcas.

The oldest method for calculating code complexity is counting the number of lines in a given function or method. The theory is simply that more lines of code imply more complexity.

Depth of inheritance is the next metric, and perhaps the easiest to understand. Stated plainly, the deeper the inheritance tree the harder it is to understand how changes in a base class may affect its subclasses.

The cyclomatic complexity formula, first developed by Thomas McCabe, is based on the number of branches in a function. Wikipedia lists several versions of the formula, all of which are based on graphing the execution flow through a function.

Maintenance complexity is a calculation based on Halstead metrics.

The final method metric offered is class coupling. It is based on the number of distinct types referenced by the method or class. This should be of particular interest to those trying to achieve loosely coupled systems.

Rate this Article

Adoption
Style

BT