title: Pattern for chained if statements
body: <p>I'm building a guitar chord finder app.  I use a multi-dimensional array to represent the fretboard.  Each element in the array is represented by a FretSpace struct which has a string property 'Note'.  In order to initialize the note properties across the fretboard, I pass details of the guitar string to work on, along with the fretboard.  This work is done in a GuitarTuner class.  Here is the FretSpace class:-</p>
  
  <pre><code>public struct FretSpace : IPlottable, IResourceConsumer
  {
      public string Note { get; set; }
  
      public int XPos { get; set; }
  
      public int YPos { get; set; }
  
      public string ResourceName { get; set; }
  
  
      public override string ToString()
      {
          return string.Format("[{0}] Note:{1} XPos:{2} YPos{3} ResourceName:{4}",
              GetType().Name, Note, XPos, YPos, ResourceName);
      }
  }
  </code></pre>
  
  <p>The guitar tuner class tunes one string at a time.  In this case, tuning means to initialise every FretSpace Note property with the correct musical note for that fret position.  In the TuneString method, I check the string we are working on and return a list of notes to apply to the chosen string.  I look at my code and it smells big time.  here is the offending portion of the TuneString method:-</p>
  
  <pre><code>public void TuneString(GuitarString stringToTune, FretSpace[,] fretboard)
      {
          List&lt;string&gt; notes = null;
  
          if (stringToTune == GuitarString.ELow)
          {
              notes = _scaleGenerator.GetScale(Scale.E).ToList();
          }
          if (stringToTune == GuitarString.A)
          {
              notes = _scaleGenerator.GetScale(Scale.A).ToList();
          }
          if (stringToTune == GuitarString.D)
          {
              notes = _scaleGenerator.GetScale(Scale.D).ToList();
          }
          if (stringToTune == GuitarString.G)
          {
              notes = _scaleGenerator.GetScale(Scale.G).ToList();
          }
          if (stringToTune == GuitarString.B)
          {
              notes = _scaleGenerator.GetScale(Scale.B).ToList();
          }
          if (stringToTune == GuitarString.EHigh)
          {
              notes = _scaleGenerator.GetScale(Scale.E).ToList();
          } //carry on and tune the string using the notes we returned
  </code></pre>
  
  <p>I am no design pattern master but I am rapidly acquiring a keen nose for code smells.  Is there a better way to do this given that the same method is being called every time but with just a different parameter.  I looked at Command.  Doesn't seem to apply where a value is returned but correct me if I am wrong.  I also looked at factory but this seems concerned with returning a family of objects, which in this case doesn't apply.  I'v searched stack overflow for the best part of an hour and can't seem to find a relevent example.  Can anyone help.  Thanks.</p>