Sunday, 25 August 2013

Using Reflection in factory pattern

Using Reflection in factory pattern

Is it a good practice to use Reflection in Factory pattern?
public class MyObjectFactory{
private Party party;
public Party getObject(String fullyqualifiedPath)
{
Class c = Class.forName(fullyqualifiedPath);
party = (PersonalParty)c.newInstance();
return party;
}
}
PersonalParty implements Party

No comments:

Post a Comment