Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   What is a Factory Method?? (http://www.go4expert.com/forums/factory-method-t1956/)

pradeep 21Nov2006 16:16

What is a Factory Method??
What is a Factory Method??

shabbir 21Nov2006 16:32

Re: 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.

pradeep 21Nov2006 16:38

Re: What is a Factory Method??
OK! So does it mean that I create the object with some different paramater and without using the constructor??

shabbir 21Nov2006 17:39

Re: What is a Factory Method??
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.

All times are GMT +5.5. The time now is 06:51.