title: Where to put comments in an if-then-else construct?
body: <p>I never decided on what the best way is to comment <code>if-then-else</code> constructs, so I never standardized on a consistent way to comment them.
  I appreciate any insights.</p>
  
  <p>Some options:</p>
  
  <p>a)</p>
  
  <pre><code>if (blabla) { 
     // this comment explains what happens in the IF case
     dothis();
  } else { 
    // this comment explains what happens in the ELSE case
     dosomethingelse();
  }
  </code></pre>
  
  <p>drawback: in case of multiple dothis() statements, I like to comment the major blocks, and in that case it isn't always clear if the IF-comment belongs to the first dothis() block or to the whole IF case</p>
  
  <p>or b)</p>
  
  <pre><code>if (blabla) { // this comment explains what happens in the IF case
     dothis();
  } else { // this comment explains what happens in the ELSE case
     dosomethingelse();
  }
  </code></pre>
  
  <p>drawback: only works for short comments. I usually comment IF-THEN-ELSE constructs if the IF and ELSE case isn't directly clear from the code, which typically requires a comment longer than one line.</p>
  
  <p>or c)</p>
  
  <pre><code>// if the following happens
  if (blabla) { // then do this
     dothis();
  } else { // or else do this
     dosomethingelse();
  }
  </code></pre>
  
  <p>PS: I know about "the code should be self explanatory", but this isn't always the case...</p>