Use the Factory Method pattern when…



  • Flexibility is important.
  • Objects can be extended in subclasses
  • There is a specific reason why one subclass would be chosen over another—this logic forms part of the Factory
  • Method.
  • A client delegates responsibilities to subclasses in parallel hierarchies.

Consider using instead....

  • The Abstract Factory, Prototype, or Builder patterns, which are more flexible (though also more complex).
  • The Prototype pattern to store a set of objects to clone from the abstract factory.