Talk:Two Wrongs Can Make a Right (and Are Difficult to Fix)

From WikiContent

Revision as of 14:44, 4 February 2009 by Kevlin (Talk | contribs)
Jump to: navigation, search

Is it really so easy to get two wrongs? IMHO it requires either the same person applying the same assumption in multiple places (violating DRY?) or people adapting to problems by creating workarounds.

E.g. with unit tests it is mostly stated that in the most cases a double wrong as well as a single wrong are easily found by the test because it's unlikely to have the same error both in the test and the code. --Michael Hunger 17:25, 26 January 2009 (PST)

Getting two wrongs is easy for precisely these reasons! Yes, people violate DRY all the time and make the same assumption in multiple places, and a lot of people spend time adapting to problems by creating workarounds. This is more normal in software development than not. Which is precisely why it is one of those things that programmers should know.

These adaptations and workarounds are one of the challenges for framework/library/API/etc. providers because they are often forced into taking support or break decisions when changing their code. Compatibility for bugs and workarounds is a perennial challenge for many systems.

As for unit tests, this problem is indeed found in some unit tests that are written after the fact and are written by first inspecting the code to be tested in order to determine what to test, rather than working from an understanding of the intended semantics. One client of mine has a couple of hundred thousand lines of test code that was written by performing white-box inspection. Bugs are now regression tested!

Kevlin Henney

Personal tools