title: How should one comment an if-else structure?
body: <p>Lets say you have:</p>
  
  <pre><code>if(condition) {
      i = 1;
  } else {
      i = 2;
  }
  </code></pre>
  
  <p>and you need to put comments explaining <code>if</code> and <code>else</code> blocks. What's the most readable way of doing it so someone can easily pick them up at first glance?</p>
  
  <p>I usually do it like this:</p>
  
  <pre><code>//check for condition
  if(condition) {
      i = 1;
  } else {
      //condition isn't met
      i = 2;
  }
  </code></pre>
  
  <p>which I find not good enough as comments are located at different levels, so at quick glance you would just pick up <code>if</code> comment and <code>else</code> comment would look like it belongs to some inner structure.</p>
  
  <p>Putting them like this:</p>
  
  <pre><code>if(condition) {
      //check for condition
      i = 1;
  } else {
      //condition isn't met
      i = 2;
  }
  </code></pre>
  
  <p>doesn't look good to me either as it would seem like the whole structure is not commented (condition might be big and take multiple lines).</p>
  
  <p>Something like that:</p>
  
  <pre><code>//check for condition
  if(condition) {
      i = 1;
  //condition isn't met
  } else {
      i = 2;
  }
  </code></pre>
  
  <p>would be probably the best style from comments point of view but confusing as a code structure.</p>
  
  <p>How do you comment such blocks?</p>
  
  <p><strong>PS.</strong> I am not asking about refactoring this two lines of code, only about code style and comment formatting. </p>