Skip to content

Files

Latest commit

ff96549 · Sep 14, 2023

History

History

Source

https://refactoring.guru/design-patterns/prototype

Important:

  1. Prototype is a creational design pattern that lets you copy existing objects without making your code dependent on their classes.
  2. A fully initialized instance to be copied or cloned

Description

Structure

alt tag

How to use

  1. Use the Prototype pattern when your code shouldn’t depend on the concrete classes of objects that you need to copy.
  2. Use the pattern when you want to reduce the number of subclasses that only differ in the way they initialize their respective objects.

How to implement

https://refactoring.guru/design-patterns/prototype#checklist

Running

python main.py
python example.py