title: Alternatives to passing a flag into a method?
body: <p>Sometimes when fixing a defect in an existing code base I might (often out of laziness) decide to change a method from:</p>
  
  <pre><code>void
  MyClass::foo(uint32_t aBar)
  {
      // Do something with aBar...
  }
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>void
  MyClass::foo(uint32_t aBar, bool aSomeCondition)
  {
      if (aSomeCondition)
      {
          // Do something with aBar...
      }
  }
  </code></pre>
  
  <p>During a code review a colleague mentioned that a better approach would be to sub-class <code>MyClass</code> to provide this specialized functionality.</p>
  
  <p>However, I would argue that as long as <code>aSomeCondition</code> doesn't violate the purpose or cohesion of <code>MyClass</code> it is an acceptable pattern to use.  Only if the code became infiltrated with flags and <code>if</code> statements would inheritance be a better option, otherwise we would be potentially be entering architecture astronaut territory.</p>
  
  <p>What's the tipping point here?</p>
  
  <p><strong>Note:</strong> I just saw <a href="https://stackoverflow.com/questions/1240739/boolean-parameters-do-they-smell/1240779#1240779">this related answer</a> which suggests that an <code>enum</code> may be a better
  choice than a <code>bool</code>, but I think my question still applies in this case.</p>