Chapter 8. The Prototype Pattern

With the Prototype pattern, you can specify the general class needed in a program but defer specifying the exact class until execution time. It is similar to the Builder pattern in that some class decides what components or details make up the final class. However, it differs in that the target classes are constructed by cloning one or more prototype classes and then changing or filling in the details of the cloned class to behave as desired.

Prototypes can be used whenever you need classes that differ only in the type of processing that they offer, for example, when parsing strings that represent numbers in different radixes. In this sense, the Prototype is nearly the same as the Exemplar pattern described by Coplien ...

Get Java™ Design Patterns: A Tutorial now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.