|
Annex B: Design PatternsB6.Factory MethodDescriptionWhen an algorithm needs to create an object whose its concrete class is variable according to the context, this owner proposes the delegation with a subclass of the instanciation of this object. Structure and Components
Structure and Components of the Factory Method design pattern
Collaborations
Strengths and Weaknesseswe do not have to specify the object to be instantiated directly and allows a subclass to choose the desired concrete object, in certain cases, the specialisation of the base-class is carried out only to specify the instantiation (heavier operation for example than to pass as a parameter the requested object). It is thus preferable to use this pattern when it is also necessary for other reasons to specialise the base-class. Use in CBR*ToolsThis pattern occurs in various algorithms of CBR*Tools and in particular in the internal protocols of the index for the creation of the objects holding the result of a search (of IndexResult class) so as to instantiate the adequate objects. Brigitte Trousse Last modified: Fri Sep 28 13:51:57 MEST 2001 |