title: Switch statement instead of multiple nested if - else?
body: <p>I've come across a situation where I have a bunch of "systems" that need to be initialized in sequence, with the next system only being initialized if all of the proceeding systems initialized successfully.</p>
  
  <p>This has led me to a whole slew of nested if - else statements. Here's some pseudo-code for visualization.</p>
  
  <pre><code>bool mainInit () {
      if (!system1Init ()) {
          reportError ();  // some error reporting function
      }
      else {
          if (!system2Init ()) {
              reportError ();
          }
          else {
              if (!system3Init ()) {
              // ... and so on
  </code></pre>
  
  <p>I find that this starts to look like a mess when you get even a handful of levels to it.</p>
  
  <p>Now I thought of using a switch statement instead, starting at the first case and falling through to the other cases on success, only breaking if there's an error.</p>
  
  <pre><code>bool mainInit () {
  
      switch (1) {
      case 1:
          if (!system1Init ()) {
              reportError ();
              break;
          }
      case 2:
          if (!system2Init ())
              reportError ();
              break;
          }
      // ....
  }
  </code></pre>
  
  <p>Now, I like this a lot better.  I find it much easier to read, especially with some decent comments, but I'm fairly new to programming.</p>
  
  <p>So, my question is: Seeing how this is not how switch statements are traditionally used(at least from what I've seen), is something like this acceptable, or would this be considered bad form?</p>
  
  <p>Being new to programming, I'm trying not to develop too many bad habits that might frustrate and make things more difficult for other programmers down the road.</p>
  
  <p>I did a search, but most of what I found had to do with replacing chains of if - else if statements, not replacing nested ones.</p>