I'm currently putting together a talk where I discuss the value of unit tests in enforcing the SOLID Open/Closed principle.

However beyond the obvious "the bug wasn't there when I wrote it, it's been introduced" I'm looking for a definitive study which proves that obeying the SOLID rule of "Open to Extension but Closed to Change" will reduce the number of bugs introduced in our code?

Are there any irrefutable studies or figures I can cite to prove the value of obeying this rule.

  • 3
    From objectmentor.com/resources/articles/ocp.pdf: "When a single change to a program results in a cascade of changes to dependent modules, that program exhibits the undesirable attributes that we have come to associate with “bad” design. The program becomes fragile, rigid, unpredictable and unreusable. The openclosed principle attacks this in a very straightforward way. It says that you should design modules that never change. When requirements change, you extend the behavior of such modules by adding new code, not by changing old code that already works." Nov 2, 2015 at 18:34
  • Is empirical evidence off topic here?
    – gnat
    Nov 2, 2015 at 19:15
  • 6
    Though of course reducing bugs is a laudable goal for many reasons, it's important to remember that reducing bugs is actually a proxy for reducing costs. The SOLID principles are for the most part good principles, but designing types that are open to meaningful extension is a tricky design problem that can increase costs, and can itself be done wrong. The question that really ought to be studied is whether the additional design cost pays for the reduced cost of fixing bugs later. Nov 3, 2015 at 19:47

1 Answer 1


There's no such thing as a definitive or irrefutable study.

However, see Bug Inducing Analysis to Prevent Fault Prone Bug Fixes, which conducts an empirical study of bugs and the means used to fix them. Section 4.2 states: "From the statistics, we can see that the percentage of typeDeclarationAdded in bug-inducing changes is much lower than in non-bug-inducing changes. Thus, we can make the assumption that typeDeclarationAdded may be a much safer way to fix a bug."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.