When to Use a Factory Pattern?
Dinesh Beniwal
A class can’t anticipate which kind of class of objects itmust create.A class uses its subclasses to specify which objects it creates.You want to localize the knowledge of which class gets created.There are several similar variations on the factory patternto recognize.1. The base class is abstract and the pattern must return acomplete working class.2. The base class contains default methods and is onlysubclassed for cases where the default methods are insufficient.3. Parameters are passed to the factory telling it which ofseveral class types to return. In this case the classes mayshare the same method names but may do something quitedifferent.