title: Is there a good design pattern for implementing optional features?
body: <p>Suppose I have a function that performs some task (this is in Python pseudocode):</p>
  
  <pre><code>def doTask():
      ...
  </code></pre>
  
  <p>But I have several optional features on the platform which results in having code that looks like this:</p>
  
  <pre><code>def doTask():
      ...
      if FEATURE_1_ENABLED:
          ...
      if FEATURE_2_ENABLED:
          ...
      ...
  </code></pre>
  
  <p>Unfortunately, this gets <strong>rather</strong> messy with many different optional features that coincide with one another. What kinds of design patterns solve this issue?</p>