This article describes the Prototype design pattern. This is a creational design pattern, a category of
design pattern used by software engineers, when writing computer programs.
Table of Contents
Introduction
The Prototype pattern is a
design pattern, used in software engineering to enable replication of an object. A prototypical instance of the object is initially created. This base/abstract class is able to clone itself. In this pattern, a
Client (eg Font Manager) requests a ConcretePrototype (Font) from the
Prototype (FontPrototype).
This pattern is defined as a
Creational design pattern because it relates to the creating of classes that are decoupled from the implementing system (they can create themselves without the requesting code having to know how to instantiate it.
Benefits
Instead of all the hassle of creating a new instance of the object, cloning is often preferred, to avoid the cost of creating new objects.
Because the clone creates a copy of itself, the implementing code doesn't need to know HOW to create it.
It is also used to avoid subclassing.
Examples of the pattern
- ICloneable interface (.Net Framework)
See Also
Link to domain parent articles and related articles in TechNet Wiki.
Community Resources
These are the external links, including links to Microsoft and TechNet sites that are non-Wiki- [Please contribute]
References section
Use this section if you pulled source material and ideas from other sites, blogs, or forums. Make sure you have permission from authors to use their material.- [Please contribute]