What is the Prototype Pattern?
The Prototype Pattern is a creational design pattern.
It enables the creation of new objects by copying an existing object, rather than creating them from scratch via their class constructors. This helps decouple code from specific classes.
Prototype: Common vs Software Usage
When I first encountered the Prototype Pattern, I was confused. The word “prototype” in daily use has a slightly different meaning, so let’s clarify that first.
Everyday Use:
A prototype usually refers to a preliminary version of a product made to test core features before mass production.
In game development, it can also mean a simplified version of the game created to test gameplay and feasibility.
In the Prototype Pattern:
A prototype is an object that supports cloning itself.
Rather than a draft or concept model, think of it like an amoeba that can self-replicate.
Despite the differences, both meanings derive from the idea of an “original form”.
The Problem
Say we want to duplicate an object.
Typical Approach:
- Use the object’s class to create a new instance
- Copy all fields from the original object into the new one
Problems:
- If fields are private, we might not be able to access them.
- The code ends up depending on the concrete class.
- If we only have an interface reference, we can’t create a new instance.
The Solution
Delegate the cloning responsibility to the object itself!
This eliminates the need to access fields externally or know the concrete class.
- Define an interface for cloning (e.g.,
clone()
). - Each class implements this method and manages its own duplication.
- Now we can duplicate via the interface without depending on the class.
Structure
1. Basic Implementation

Prototype Interface
|
|
ConcretePrototype
|
|
RedCircle Example (Subclassing)
|
|
Client
|
|
2. Prototype Registry
You can manage prototypes using a registry or collector.
This hides the creation logic from clients—they simply fetch from the registry.
In this context, clients may either:
- Initialize and register objects to the registry.
- Fetch existing prototypes from the registry.

Limitations in Java
You often need to cast objects after cloning to access subclass-specific methods.
|
|
As shown above, casting is required to access subclass-specific methods.
This defeats the purpose of polymorphism and makes the pattern less elegant in Java.
Hence, this pattern may be more suitable in dynamically typed languages like Python or JavaScript.
Related Patterns
- Can be used as an alternative to complex Factory Methods.
- Abstract Factory can internally use Prototype to generate objects.