Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat do you think when a Boolean "if" has three resulting code paths?
    text
    copied!<p>(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...)</p> <p>Reported by:</p> <p>QA tester was reading HTML/JS code to write a functional test of a web form, and saw:</p> <pre><code>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 } </code></pre> <p>After a couple embarassing attempts, tester realized that they couldn't trigger the alert strings hidden in the third block.</p> <p>Things I'm wondering are:</p> <ul> <li>Is this problem more or less language specific (can non-JS people learn lessons here?)</li> <li>Are there legitimate reasons code ended up this way?</li> <li>What approaches should be used to find/address the problem (code coverage, code review, blackbox testing, etc.)</li> </ul> <p>A couple other points:</p> <ol> <li><p>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.</p></li> <li><p>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.</p></li> </ol> <p>[EDIT] Similar to <a href="https://stackoverflow.com/questions/114342/what-are-code-smells-what-is-the-best-way-to-correct-them">https://stackoverflow.com/questions/114342/what-are-code-smells-what-is-the-best-way-to-correct-them</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload