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.
- 1Prepare a prototype
- 2Clone it
- 3Modify the clone
- 4Use it
1/4
Step by step
- 1Prepare a prototype
- 2Clone it
- 3Modify the clone
- 4Use it
Where it is used
Expensive-to-create objects.
Watch out for
Deep copy pitfalls.