title: Determine factory to use when using the Factory Method Design Pattern
body: <p>I am currently doing some research on the factory design patterns and have listed a brief description of my understanding of each. Please correct me if any of them are not correct.</p>
  
  <p>1) Factory - simple and not actually an official design pattern, usually one class which has one or more methods (sometimes static) accepting a parameter to determine which subclass of the abstract type to return.</p>
  
  <p>2) Factory Method - officially a pattern and uses a abstract factory class. For each product of the intended return type, create an associated factory class and either implement or override the required methods. In the client code, although the variable is declared as the abstracted factory, it is instantiated with the concrete implementation.</p>
  
  <p>3) Abstract Factory - a pattern to return more than one type of object through various methods that are either related or dependent upon each other.</p>
  
  <p>My question is, i have been using the factory (not officially a pattern) with shared methods. However, i am looking at picking up the factory method and using this, but what i cannot get my head round is how i would determine which subclass of the abstracted factory class to use to create my product. From what i understand so far, you still use the <em>new</em> keyword to assign a concrete class to the variable declared as the abstract factory class.</p>
  
  <p>For example:</p>
  
  <p>Dim factory1 As IFactory = New ConcreteFactory1</p>
  
  <p>Dim factory2 As IFactory = New ConcreteFactory2</p>
  
  <p>If i want to dynamically determine which IFactory i would like to return based on a database record for instance, how would i do that? Am i better off leaving the code using the Factory pattern and not bother with the Factory Method pattern? I want to avoid doing a <em>select case</em> or <em>if</em> statement in the client code. Could i wrap the Factory Method pattern in a Factory pattern?</p>
  
  <p>Hope i have made sense</p>