Factory method pattern
The FactoryMethodPattern is one of the DesignPatterns discussed in the GangOfFour book of the same name. (Page 107)
It allows classes to defer object creation to a separate method (a FactoryMethod). This would be an additional method on existing classes in a hierarchy.
See also: AbstractFactoryPattern, ClassFactory, DesignPatterns
http://wiki.cs.uiuc.edu/PatternStories/FactoryMethodPattern
http://www.patternsinperl.com/designpatterns/factorymethod/ - Perl implementation
http://gsraj.tripod.com/design/creational/factory/factory.html
The factory method ensures an interface which returns the product type depending on the implementation of the creator class..It's similar to Abstract Factory in that the methods of the Abstract factory can be implemented as factory methods.The main difference is that while abstract factory deals with a family of products,the factory method is only worried about a single product. Praveen.
Factory methods are sometimes used in place of constructors for any of several reasons: * Some languages (such as Java) do not allow constructors to have useful names * Some languages (such as Java) do not allow constructors to have different names (which may be necessary if you want to use the same method signature for two constructors) * To allow the same instance to be reused instead of recreated each time it is needed (see FlyweightPattern)
CategoryPattern | CategoryCreationalPatterns