A class pattern that defines an interface for creating an object but lets subclasses decide which class to instantiate lets a class defer instantiation to subclasses.
Product
(e.g., Document)ConcreteProduct
(e.g., MyDocument)Creator
(e.g., Application)ConcreteCreator
(e.g., MyApplication)Creator
relies on subclasses to define the factory method so that it returns an instance of the appropriate ConcreteProduct
Product
interfaces so that it can work with any user-defined ConcreteProduct
classesCreator
for each unique ConcreteProduct
CreateFileDialog
, that subclasses can override if neededFactory methods pervade toolkits and frameworks