(Background: from a previous job, a co-worker and I would end up discussing the bug pile during lunch. We began to develop a topic called "bug of the week". I doubt I have material for 52 posts a year, but here's the first one...)
Reported by:
QA tester was reading HTML/JS code to write a functional test of a web form, and saw:
if (form_field == empty)
{
...do stuff for empty field
}
else if (form_field != empty)
{
...do stuff for non-empty field
}
else
{
...do stuff that will never be done
}
After a couple embarassing attempts, tester realized that they couldn't trigger the alert strings hidden in the third block.
Things I'm wondering are:
- Is this problem more or less language specific (can non-JS people learn lessons here?)
- Are there legitimate reasons code ended up this way?
- What approaches should be used to find/address the problem (code coverage, code review, blackbox testing, etc.)
A couple other points:
I'm hoping we can keep it positive. Imagine this is a person you work with (in a company that does not encourage flaming). Whatever mean things you might think of the guilty party, I probably already thought them too.
I'm not a coder by profession. I checked the wiki box, in case someone wants to provide a more literal example, or add to the base of the thread.
[EDIT] Similar to http://stackoverflow.com/questions/114342/what-are-code-smells-what-is-the-best-way-to-correct-them