Sunday, April 19, 2009

What is Defect Density?

Defect Density

Defect density is a measure of the total known defects divided by the size of the software entity being measured. (By Linda Westfall)


Size is either in LOC or Function Points.

Defect Density is a classical measure of software quality.

A Defect Density of 100 defects per thousand lines of code means that for every thousand lines of code, 100 defects remain. The smaller the ratio, the higher the quality of your software product and vice versa.[Source]

For Example if a specific functionality has a high defect density, an analysis should be conducted:

> Is this functionality very complex and therefore it would be expected that the defect density would be high?
> Is there a problem with the design/implementation of the functionality?
> Were wrong (or not enough) resources assigned to the functionality, because an inaccurate risk had been assigned to it?
> It also could be inferred that the developer responsible for this functionality needs more training. [Source]

Below table shows size of the three major subsystems that make up the ABC software system and the number of pre-release and post-release defects discovered in each subsystem.

Defect density example inputs.
SubsystemSizePrerelease defectsPost-release defects
A3432 LOC645
B2478 LOC3212
C6912 LOC10223

Post-release defect density in defects per KLOC would be calculated as follows:

Size of ABC = 3432 + 2478 +6912 = 12822 LOC

Post-release defects = 5+12+23=40 defects

Defect density = 40 defects/12822 LOC
= .00312 defects per LOC
= 3.12 defects per KLOC

Defect density is used to compare the relative number of defects in various software components. This helps identify candidates for additional inspection or testing or for possible reengineering or replacement. [Source of this example: The Certified Software Quality Engineering Handbook by Linda Westfall]

Defect Density can be used to

1) Predict the remaining defects when compared to the expected defect density,
2) Determine if the amount of testing is sufficient, and
3) Establish a database of standard defect densities. [Source]

Also See:

Defect Removal Efficiency
Test Coverage
Test Effectiveness
Schedule Variance & Cost Variance
Effort Variance