A Gang of Four creational design pattern that creates a new object by cloning an existing, fully configured instance rather than constructing one from scratch, useful when creating an object directly is more expensive than copying one.
Facts
Core PrincipleCreates new objects by cloning an existing prototypical instance rather than by instantiating a class directly, avoiding a parallel hierarchy of creator subclasses. 2 Connections
Associated With
Erich Gamma, Pioneers Erich Gamma co-authored the 1994 Design Patterns book that named and catalogued the Prototype pattern among the original 23.
In Field
Sources
1. Wikipedia: Design Patterns (book)
Wikimedia FoundationLead section, first sentenceQuote, Lead section, first sentence
Design Patterns: Elements of Reusable Object-Oriented Software (1994) is a software engineering book describing software design patterns.
View the Source 2. Wikipedia: Prototype Pattern
Wikimedia FoundationLead section, second sentenceQuote, Lead section, second sentence
It is used when the types of objects to create is determined by a prototypical instance, which is cloned to produce new objects.
View the Source Frequently Asked Questions
Why does the Prototype Pattern clone an existing object instead of building a new one from a class?
It clones a prototypical instance instead of instantiating a class directly.
The Prototype Pattern creates new objects by cloning an existing prototypical instance rather than instantiating a class directly. It is used when the types of objects to create are determined by a prototypical instance, which is cloned to produce new objects, avoiding a parallel hierarchy of creator subclasses that a class based approach would otherwise require.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.