● One of Creational Patterns
● Others: Singleton, Factory Method, Abstract
To make dynamic creation easier by defining
classes whose objects can create
duplicates of themselves.
Sometimes, it becomes necessary to copy
or clone an “already grown” object rather
than instantiating it and setting its values.
- Use the Prototype pattern when you want to create an
object that is a copy of an existing object.
- When instances of a class can have one of only a few
different combinations of state.
Shallow vs Deep Copy
● A shallow copy duplicates only the top-level
elements of a class; this provides a faster copy, but
isn’t suitable for all needs.
● Deep copy operations replicate not only the top-level
attributes, but also the lower-level objects. This
typically takes longer than shallow copy operations,
and can be very costly for objects with an arbitrarily
● Abstract Factory – Abstract Factories can
use the Prototype to create new objects
based on the current use of the Factory.
● Factory Method – Factory Methods can
use a Prototype to act as a template for
Pros and Cons
● Hides the complexities of making new instances from
● In certain circumstances, copy an object is more
efficient than creating a new object
● Using a Prototype design pattern hides concrete
product classes from the client
● Classes can be difficult to deep clone