Discussion in 'Programming' started by pradeep, Nov 21, 2006.
What is a Factory Method??
In Factory methods you normally have methods to create objects something like CreateXXXX taking the string as the parameter.
It creates objects of type derived classes which is hidden and you have base class which exposes all the methods and operation a derived class can handle.
As an example
Class Fruit has lots of methods like Cut, Mix and you have some general function like CreateFruit which takes a string and create an object of type of derived classes and return you the object and you can operate on the object without knowing the details of the object but you know some general things from Fruit.
OK! So does it mean that I create the object with some different paramater and without using the constructor??
Nope. You as a user of such a method does not need to create the objects of subtype identifying them but you just need to know the string. Constructor is actually called but that is done by CreateXXXX method.
Separate names with a comma.