QA glossary
What is defect density?
Defect density is the number of confirmed defects found in a piece of software divided by its size, usually per thousand lines of code (KLOC) or per function point. It lets a team compare the quality of modules or releases of different sizes on the same scale.
An example from QA practice
Module A has 12 confirmed defects in 6 KLOC, a density of 2.0 per KLOC. Module B has 15 confirmed defects in 30 KLOC, a density of 0.5. Module B has more bugs in total, but module A is the one to review, because its code produces four times as many defects for its size.
What makes the number honest
The figure is easy to calculate and easy to distort. Four rules keep it meaningful:
- Count only confirmed defects. Duplicates and rejected reports inflate it.
- Use the same size measure every time. Lines of code and function points do not mix.
- Compare like with like: the same period, the same test depth, the same kind of module.
- Read it beside coverage. A low density can mean clean code, or it can mean little testing.
What it is for
Density points to where to look, not who to blame. It helps decide which module needs a code review, where extra testing pays off, and whether a release is trending better or worse than the last one.
How BetterQA does it
Our defect tracker, BugBoard, keeps each report with its severity and status, including won't fix, so reports that were never going to be fixed can be set apart before a density figure is calculated. Duplicates still need a person to merge them first.
Related terms
Severity is the usual way to weight the defects you count.