The Factory Method pattern deals with creation of objects in which the
subclasses decide which class’s object has to be created. Various
subclasses may implement the same interface, but the Factory Method
creates the appropriate object based on some supplied information.
As seen in the above example, the instantiation of objects is handled by
the FactoryMethod of the Creator class. In this method, the information
being passed helps the method in deciding which object to create. We
must use the Factory method pattern when we want the flexibility of
creating objects based on some criteria or the objects can be extended
In my next post I will talking about the Singleton pattern.