title: Creating different types based on some criteria
body: <p>I have some code in an application that I am not really thrilled about right now. I created a few classes like so:</p>
  
  <pre><code>class Base
  {
     // base properties ...
  }
  
  class DerivedA : Base
  {
  }
  
  class DerivedB : Base
  {
  }
  </code></pre>
  
  <p>I have a method in my application that needs to create one of these objects (with more to come in the future) based on a string property that is stored in the database. Each one of these objects gets its data from slightly different places, but the way I'm doing it right now is just a big if block and it doesn't seem very maintainable:</p>
  
  <pre><code>class BaseCreator
  {
      Base Create(string name)
      {
          if (name == "DerivedA" )
              return CreateDerivedA();
          else if(name == "DerivedB")
              return CreateDerivedB();
      }
  }
  </code></pre>
  
  <p>What are some ways I can refactor this code to be more maintainable and make it easier to add new types in the future? I am using dependency injection (Ninject) in my application if that makes any difference.</p>