The standard defect density metric is defined as the number of defects discovered normalized by code size. Each of these elements needs a crisp definition: all defects, all severity levels, only open defects; EKLOC, logical KLOC, function points.
In our defect density defintion, the goal of the metric is provide one measure of the amount of rework required. Therefore, we measure total defects of all severity levels. We also measure EKLOC, although we agree that function points are a better measure for this metric but more difficult to measure in an automated manner. So we compromised.
Imagine a large program with 1 million lines of code. Of that 1 million lines, only 10% of those lines are in active development and 90% of the lines are legacy that are rarely or never touched. We felt that changed defect density would be a another useful metric since it would be measuring where people were working and would not be diluted. Our first thought was to measure defects normalized by changed lines of code.
The tool we use to measure LOC also measures code churn (add, deleted or modified from the previous version). Knowing where code churn is the greatest is useful to the development and test team for obvious reasons. However, code churn measures the amount of change from one version to the next and not the lines of code that have changed over time.
If we imagine a single source file that has had the same line of code changed 10 time over 10 revisions, then the number of lines of code that have changed is 1, and the number of changes to that file over all revisions is 10 (churn). It seems impossible for a tool to determine the number of lines of code that have changed over a period of time.
In your experience, is it useful to measure defects normalized by aggregated code churn (the number of changes to all files over time)? Is this a defect density metric? Has anyone used a similar metric?
Bob Brown, Intel Corp, Intel Software Quality