Prototype
Intent
Specify the kinds of objects to create using a prototypical instance,
and create new objects by copying this prototype.
Participants
-
Prototype -
declares an interface for cloning itself.
-
Concrete Prototype -
implements an operation for cloning itself.
-
Client -
creates a new object by asking a prototype to clone itself.
Examples
-
OOLs that use object-based inheritance create an object by copying a
prototype instance members.
The values of its members can then be overridden.
-
A tool from a toolbar in a graphics editor program can carry a
prototype to create the objects that it draws.
It also has a controller that uses mouse actions to modify the
clones.