title: Is there such a thing as too many embedded if-statements?
body: <p>Currently I am working on a bit of code which (I believe) requires quite a few embedded if statements. Is there some standard to how many if statements to embed? Most of my googling has turned up things dealing with excel..don't know why.</p>
  
  <p>If there is a standard, why? Is it for readability or is it to keep code running more smoothly? In my mind, it makes sense that it would be mainly for readability.</p>
  
  <p>An example of my if-structure:</p>
  
  <pre><code>if (!all_fields_are_empty):
      if (id_search() &amp;&amp; validId()):
          // do stuff
      else if (name_search):
          if (name_exists):
              if (match &lt; 1):
                  // do stuff
          else:
              // do stuff
      else if (name_search_type_2):
          if (exists):
              if (match &lt; 1):
                  // do stuff
          else:
              // do stuff
  else:
      // you're stupid
  </code></pre>
  
  <p>I have heard that there's a limit to 2-3 nested for/while loops, but is there some standard for if-statements?</p>
  
  <p><strong>Update:</strong>
  I have some years under my belt now. Please don't use this many <code>if</code> statements. If you need this many, your design is probably bad. Today, I LOVE when I can find an elegant way to do these things with minimal <code>if</code> statements or <code>switch</code> cases. The code ends up cleaner, easier to test, and easier to maintain. Normally.</p>