Prototype Design Pattern

Prototype is a build design pattern that allows you to copy existing objects without making your code dependent on their classes.

Declare an abstract base class that specifies a pure virtual “clone” method, and maintain a dictionary of all concrete “cloneable” derived classes. Any class that needs a “polymorphic constructor” capability: It derives from the abstract base class, registers its prototypical instance, and implements the clone () operation.

So the client, instead of writing code that invokes the “new” operator on a wired class name, calls a “clone” operation on the abstract base class, supplying an enumerated string or data type that designates the class desired derivative.

Lets see PHP & C# code samples as below.



By Yuuma.




tel. 06-6454-8833(平日 10:00~17:00)