concept defect in category software development

appears as: defects, defect
Test Driven: Practical TDD and Acceptance TDD for Java Developers

This is an excerpt from Manning's book Test Driven: Practical TDD and Acceptance TDD for Java Developers.

Riddled with defects

Defects create unwanted costs by making the system unstable, unpredictable, or potentially completely unusable. They reduce the value of the software we deliver—sometimes to the point of creating more damage than value.

The way we try to get rid of defects is through testing—we see if the software works, and then we try to break it somehow. Testing has been established as a critical ingredient in software development, but the way testing is traditionally performed—a lengthy testing phase after the code is “frozen”—leaves much room for improvement. For instance, the cost of fixing defects that get caught during testing is typically a magnitude or two higher than if we’d caught them as they were introduced into the code base. Having defects means we’re not able to deliver. The slower and the more costly it is to find and fix defects, the less able we become.

Defects might be the most obvious problem with poorly written code, but such code is also a nightmare to maintain and slow and costly to develop further.

Evidenced by the quality assurance departments of the corporate world of today, people tend to associate the word quality with the number of defects found after using the software. Some consider quality to be other things such as the degree to which the software fulfills its users’ needs and expectations. Some consider not just the externally visible quality but also the internal qualities of the software in question (which translate to external qualities like the cost of development, maintenance, and so forth). TDD contributes to improved quality in all of these aspects with its design-guiding and quality-oriented nature.

Quite possibly the number one reason for a defect to slip through to production is that there was no test verifying that that particular execution path through our code indeed works as it should. (Another candidate for that unwanted title is our laziness: not running all of the tests or running them a bit sloppily, thereby letting a bug crawl through.)

TDD remedies this situation by making sure that there’s practically no code in the system that is not required—and therefore executed—by the tests. Through extensive test coverage and having all of those tests automated, TDD effectively guarantees that whatever you have written a test for works, and the quality (in terms of defects) becomes more of a function of how well we succeed in coming up with the right test cases.