SE450: PROTOTYPE Pattern [37/63] Previous pageContentsNext page

Context

  1. A system instantiates objects of classes that are not known when the system is built.
  2. You do not want to require a separate class for each kind of object.
  3. You want to avoid a separate hierarchy of classes whose responsibility it is to create the objects.

Solution

  1. Define a prototype interface type that is common to all created objects.
  2. Supply a prototype object for each kind of object that the system creates.
  3. Clone the prototype object whenever a new object of the given kind is required. 

Previous pageContentsNext page