|
Annex B: Design PatternsB8.PrototypeDescriptionWhen we want to create an object starting from an existing object, this pattern proposes the definition of a method of cloning which masks in the client the effective operations of duplication. Structure and Components
Structure and Components of the Prototype design pattern
Collaborations
Strengths and Weaknessesthe encapsulation of the creation of an object and the client does not have explicit knowledge on the class of this object, allows the dynamic definition of classes of objects ratjer than a static definition made at compilation, allows the establishment of objects which are not differed by modifications made incrementally, the implementation of an operation of cloning can be difficult if there are components which cannot be cloned (operation of cloning not previously defined) or if there are circular references, the depth of the cloning of the components to be implemented can depend on the context of use. Use in CBR*ToolsThis pattern is used for the constitution by cloning of a library of measurements of similarity, for the copying of weight vectors and for the configuration of the traverse of the indices. To carry out these clones, all the accessible objects from a similarity establish to themselves an operation of cloning. This operation turns over a new object identical to the prototype or the same object, if this one is non-modifiable (it will thus be shared by all the clones). Brigitte Trousse Last modified: Fri Sep 28 13:52:19 MEST 2001 |