structure Prototype Concrete Concrete Client Clone() Clone() Clone() Operation() p = prototype->Clone() Return copy of itself Return copy of itself
participants Prototype Declares an instance for cloning itself Concrete Prototype Implement an operation of cloning itself Client Creates an object by asking the prototype to clone itself
consequences Specifying new objects by varying values. Specifying new objects by varying structure. Reduced subclassing. Configuring an application with classes dynamically. Adding and removing products at run-time.
applicability When a system should be independent of how its products are created, composed, and represented. When the classes to instantiate are specified at run-time To avoid building a class hierarchy of factories that parallels the class hierarchy of products When instances of a class can have one of only a few different combinations of state.
Implementation issues Implementing the Clone operation. Binding the concrete prototypes