The Prototype pattern is a creational GoF design pattern by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides that specifies the kinds of objects to create through a prototypical instance and creates new objects by copying it. Cloning a prototype keeps a system independent of how its products are created, lets the classes to instantiate be chosen at runtime and avoids a factory hierarchy that mirrors the product hierarchy.
GoF-Prototype Pattern
Details
- Full Name
-
GoF Prototype Pattern (Creational)
Intent:
Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
When to Use:
-
When a system should be independent of how its products are created and represented
-
When classes to instantiate are specified at runtime
-
When you want to avoid building a class hierarchy of factories that parallels the class hierarchy of products
Prompt Example:
"Verwende das GoF-Prototype Pattern, um neue Konfigurationsobjekte durch Klonen eines Prototypen zu erzeugen, statt sie jedes Mal von Grund auf zu konstruieren."
Related Anchors:
-
GoF Design Patterns (Umbrella)