Friday, August 10, 2007

Design Pattern > Creational > Factory



• A Factory Pattern is one that returns an instance of one of several possible classes depending on the data provided to it
• Usually all the classes it returns should have a common base class and common methods, but implementations of the methods may be different
• Following is an UML representation of the Factory Method Pattern. Note that no instances of Class derived1 or derived2 are directly created
• Factory class’ doIt() method is used to get the objects, and object type is determined on the basis of information passed to getObject() method

No comments: