Context:

Creating objects by pointing at an example in a series of objects, which may be of diverse types, or differ in content.

Challenges:

  • To separate the capability to actually create specific objects from the factory.
  • To add the capability to create objects to the factory during runtime.
  • To create a true replica of the selection.

Skill:

Participants:

Factory:

A Singleton. Registers Product protoypes. Responsible for creating products by position.

Product:

What the factory is declared to create. One or more prototypes for each concrete Product type are registered in the factory as creators.

Concrete Product:

What the factory will create for a certain position. Responsible for creating replicas of itself.

Client:

Obtains products from the factory, supplying key.

Signature:

Factory references Product protoypes and creates products for Client.

Used patterns and idioms:

 Either Prototype. Optionally: Static Registration idiom.

Used by:

Serialization mechanisms, visual selection mechanisms and generally: entry-points for objects from outside program memory.

Scope:

General.