Originally posted by pvsr rao:
Hi,
I have one doubt on factory design pattern
Actually in our project we are creating the object using factory class
suppose to create an object of the class
Plan_f.getFactory().create();
but wecan also do,ike this
PLan_f f= new Plan_f(;
what is the advantage of creating an object by using factory classes
Well, you see "PLan_f f= new Plan_f()", the
new operator is working with a concrete class
Plan_f. What if you need to use
Plan_f1 (maybe a subclass of Plan_f) ? You have to open your
IDE, change your code, then recompile and finnally you need to redeploy it. Now that there is
Factory pattern, you can specify a default class in your configuration file and let the factory determine which concrete class it should use when it is runtime. All you have to do is just modify a text line
in the config file. After that you can enjoy a
coffee or something else.
[ March 11, 2008: Message edited by: Roger King ]