Home
Prototype Pattern
Intent
- specifying the kind of objects to create using a prototypical instance
- creating new objects by copying this prototype
Implementation
The pattern uses abstract classes, as we will see below and only three types of classes making its implementation rather easy.
The classes participating to the Prototype Pattern are:
- Client - creates a new object by asking a prototype to clone itself.
- Prototype - declares an interface for cloning itself.
- ConcretePrototype - implements the operation for cloning itself.
The process of cloning starts with an initialized and instantiated class. The Client asks for a new object of that type and sends the request to the Prototype class. A ConcretePrototype, depending of the type of object is needed, will handle the cloning through the Clone() method, making a new instance of itself.

No comments:
Post a Comment