Prototype Pattern

noun

say it: “PROH-tuh-type PAT-urn” /ˈproʊtəˌtaɪp ˈpætərn/

A design pattern where an object copies itself, so a new one starts as a duplicate and only what is different is changed.

What is the Prototype pattern?

The Prototype pattern lets an object make a copy of itself, so a new object starts as a duplicate of one that's nearly right and only what's different is changed. "Same as last week, new address" becomes last_week.copy(), then a new address. The copy lives in the class that knows every field, so no field is forgotten; decide whether the copy shares the lists inside it (a shallow copy) or gets its own (a deep copy).

In a sentence

  • “After the Prototype pattern put a copy method in the shipment, the repeat button stopped losing the gift wrap.”

Level: Journeyman · More OOP terms at this level

Updated