Skip to content
StackDecode
System Design
15. Software Design PatternsAnimated walkthrough

Prototype Pattern

Create objects by copying existing ones.

The idea

Clone a prepared object instead of building from scratch.

Watch it work

The steps light up one at a time. Use the controls to pause or step through.

  1. 1Prepare a prototype
  2. 2Clone it
  3. 3Modify the clone
  4. 4Use it
1/4

Step by step

  1. 1Prepare a prototype
  2. 2Clone it
  3. 3Modify the clone
  4. 4Use it

Where it is used

Expensive-to-create objects.

Watch out for

Deep copy pitfalls.

Related