I found a bug last night with such an illustrious history that I need to document it.
SiteBuilder has the concept of resource dependencies: when you publish a page with images, both the page and images need to get uploaded. We have code that analyzes element properties to find these dependencies.
For my new feature I added a new dependency. While reviewing my code later, I realized that it shouldn't work. In fact, the whole system shouldn't work! Both the code and the comments explicitly state that what I did was wrong.
Half an hour of head scratching later, here is what I uncovered:
- 9/2005 - Coder 1 adds a check that applies to a limited set of circumstances.
- Unfortunately(?) it contains a typo. Element[@copyrightFooter!=''] should be Element[@copyrightFooterStyle!='']. This causes the change to apply much more broadly than intended (bug 1).
- 9/2005 - Coder 2 adds code which relies on this typo. It also contains a new bug (bug 2)
- 9/2006 - Coder 3 adds an entire subsystem relying on the typo.
- 9/2007 - Intern 1 adds code which relies on the typo and contains a third bug (bug 3).
- 9/2007 - I fix bug 3, but fail to notice the typo.
- 9/2008 - I fix bug 2, which was now three years old, by refactoring the code. I fail to notice the typo.
- 3/2009 - Coder 4 refactors Intern 1's code, but fails to notice the typo.
- 2/2010 - Five years after the typo was introduced, I stumble across it. Fixing it immediately breaks the entire resource-dependency system.
I know that the right approach is to add tests and refactor. In the interest of time, I will probably just remove the typo and update the comments to pretend that this was intentional all along. :)