Here's a theory of software quality for you: software must be nurtured. The existence of bugs isn't mysterious to any honest programmer. They are the product of neglect. Finding a bug in one's code isn't so much a surprise as a feeling of deja vu. Ohhhh yesssss, I remember thinking I should check that condition. Programmers have complete control over the quality of their code and, when working on code they care about, tend to produce things that work. The secret is to care for the programmers, so that they take good care of the software.