title: Re-design suggestions for the attached code segment
body: <p>My program needs to run like this:</p>
  
  <pre><code>./myprogram inputType [Can be I1, I2 or I3]
  </code></pre>
  
  <p>Most of the functions of this program are like:</p>
  
  <pre><code>void Foo::foo (IType inputType) {
      // Some common code
      if (inputType == I1) ... // some I1 specific code
      if (inputType == I2) ... // Some I2 specific code
      ...// similarly for I3
  }
  </code></pre>
  
  <p>These checks of inputType are scattered over multiple places and with time have became increasingly difficult to manage. I have thought of refactoring this code to something like :</p>
  
  <pre><code>InputType* iType = new InputTypeI1(); // or I2 or I3
  
  void Foo::foo (IType inputType) {
      // Some common code
      iType.DoSomething(this, arg1, arg2,..)
  }
  
  class InputType1 : public InputType 
  {
       // Virtual functions.. (with default implementations)
  }
  
  InputType1::DoSomething(Foo* f, Arg1* arg1, Arg2* arg2)
  {
      f-&gt;DoSomethingFor1(arg1, arg2);
  }
  </code></pre>
  
  <p>This results in organizing things for I1, I2 or I3 as well as automatically call relevant function based upon the input type.
  However, I feel this could be done better. Any suggestions?</p>