Code Metrics: How good is your code ?
Code review and code metrics are two facts of life that a good developer cannot (or should not) escape. Code metrics are ways of quantifying traits about your source code that can give developers feedback about the quality of the source code. Code metrics are usually run by an automated process like a continuos integration process (see Continuous Integration: Going Beyond Builds). Setting up a process to generate code metrics and collecting them at intervals is quite easy. However code metrics is a slippery slope because it will also give you tools to squarely point a finger at your developers and tell them how bad their code is, when in reality nothing may be wrong with their code. It is very important to know how to interpret the metrics in the context of your application and developers. So let's have a look at few of those metrics.
One of the most often used metrics is LoC (Lines of Code) or KLoC (Kilo Lines of Code). It is either the most liked metrics (mostly managers) or the most hated metric (mostly developers). Simply put it is the number of lines of code your developers can hammer out, not counting the comments, spaces and auto generated code. Some people tend to equate this to productivity and that may or may not be true based on the context in which it is interpreted. More often than not by itself this metric is not very useful, however it does need to be measured as it can provide a base for other useful metrics like LoC/class or function, bug density i.e. number of bugs per lines of code, etc both of which should always be low.
You can read the complete article here Code Metrics: How good is your code ?