# What is Defect Density and how can we calculate Defect Density ?

#### safoora Profile Answers by safoora

• Feb 4th, 2007

Defect density is one of the metric which is equal to the ratio of number of defects to the number of lines of code .

#### Sachin Umrikar

• Mar 7th, 2007

Defect Density:

Defect Density = Defect/unit size

Ex: Suppose 10 bugs are found in 1 KLOC
Therefore DD is 10/KLOC

#### preethi.gollamandala Profile Answers by preethi.gollamandala

• Aug 11th, 2009

Defect Density is the number of confirmed defects detected in software/component during a defined period of development/operation divided by the size of the software/component.
Elaboration The 'defects' are:

• confirmed and agreed upon (not just reported).
• Dropped defects are not counted.

The ‘period’ might be for one of the following:
• for a duration (say, the first month, the quarter, or the year).
• for each phase of the software life cycle.
• for the whole of the software life cycle.
The ‘size’ is measured in one of the following:
• Function Points (FP)
• Source Lines of Code
Defect Density Formula

Number of Defects
Defect Density =  --------------------------------

Size

Defect Density Uses

• For comparing the relative number of defects in various software components so that high-risk components can be identified and resources focused towards them
• For comparing software/products so that ‘quality’ of each software/product can be quantified and resources focused towards those with low quality.

#### mathan_vel Profile Answers by mathan_vel Questions by mathan_vel

• Sep 9th, 2009

Defect density is a measure of the total known defects divided by the size of the software entity being measured.

Number of Known Defects
---------------------------------
Size

The Number of Known Defects is the count of total defects identified against a particular software entity, during a particular time period. Examples include:
Defect to date since the creation of module
Defects found in a program during an inspection
Defects to date since the shipment of a release to the customer

Size is a normalizer that allows comparisons between different software entities (i.e., modules, releases, products).
Size is typically counted either in Lines of Code or Function Points.

Uses: 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.

#### kurtz182 Profile Answers by kurtz182 Questions by kurtz182

• Dec 19th, 2009

Defect density is a metric used to make informed decisions about software quality.

Defect density = # of defects / unit or component size

The size is measured in:
> Software lines of code (SLOC)
> Function points (FP)

This measure is often used to determine high-risk components that will require more attention in future projects.  It is also used to provide a baseline for process improvements.