title: Should I check whether a method is executed inside or outside of the method itself?
body: <p>I have a method which should be executed if a boolean is true.<br>
  The normal way to achieve this would be: </p>
  
  <pre><code>private void OneMethod() {
      if (ShouldExecute)
         OtherMethod();
  }
  
  private void OtherMethod() {
      Do Stuff...
  }
  </code></pre>
  
  <p>Note that the varibale "ShouldExecute" is a global variable of the class.  </p>
  
  <p>But a colleague of mine recently started to put the <code>if</code> into the method itself.<br>
  So now it looks like this:  </p>
  
  <pre><code>private void OneMethod() {
         OtherMethod(ShouldExecute);
  }
  
  private void OtherMethod(bool shouldExecute) {
      if (shouldExecute) {
          Do Stuff...
      }
  }
  </code></pre>
  
  <p>He argues that the decision, whether the method should be executed, is a function of the method itself and thus should be a part of the method.</p>
  
  <p>While i can see where he is coming from i still don't like his way. I think it just seems wrong and confusing.<br>
  If I see something like this:</p>
  
  <pre><code>var list = FilterList(list, otherParameter, yetAnotherParameter, shouldExecute);
  </code></pre>
  
  <p>I wouldn't read all of the parameters if they don't particually interest me. I would assume, that the list is somehow filtered by some parameters. Always.</p>
  
  <p>But my argument "it feels wrong" is a pretty bad argument.<br>
  His way may clash with "Seperation of concerns" or the "Single responsibility principle" as well, which would be a stronger argument, but I'm not sure if that is the case.</p>
  
  <p>But i really couldn't find any strong evidence for either of the two standpoints. And i don't really know what to search for, either...</p>
  
  <p>So maybe someone here knows which way is more in line with the object-oriented programming paradigm.<br>
  And my goal is not to proof my colleague wrong, although i would be happy if were right, of course. :)<br>
  My goal is to find a good base on which we can create a policy for this case in our company's programming standards.</p>
  
  <p>Thank you for your help.</p>