Prototype Design Pattern

 UML diagram
 sample code in C#


Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.

Frequency of use:   medium

UML class diagram


    The classes and/or objects participating in this pattern are:

  • Prototype  (ColorPrototype)
    • declares an interface for cloning itself
  • ConcretePrototype  (Color)
    • implements an operation for cloning itself
  • Client  (ColorManager)
    • creates a new object by asking a prototype to clone itself

sample code in C#

This structural code demonstrates the Prototype pattern in which new objects are created by copying pre-existing objects (prototypes) of the same class.

Show code

// Prototype pattern -- Structural example

This real-world code demonstrates the Prototype pattern in which new Color objects are created by copying pre-existing, user-defined Colors of the same type.

Show code

// Prototype pattern -- Real World example

This .NET optimized code demonstrates the same real-world situation as above but uses modern, built-in .NET features, such as, generics, reflection, object initializers, automatic properties, etc.

Show code

// Prototype pattern -- .NET optimized

   Better Code 
   Better Career 
   Better Lifestyle 

Design Pattern
Framework 4.5

C# and VB.NET


  Gang of Four Patterns
  Head First Patterns
  Enterprise Patterns
  Multi-Tier Patterns

  Repository Pattern
  Unit-of-Work Pattern
  CQRS Pattern
  Active Record Pattern

  Model View Controller
  Model View Presenter
  Model View ViewModel

  SparkTM RAD Platform
  Art Shop MVC Application
  Much more...

Click here for details

-- Instant Access --
Instant Download