Overview
The Prototype Design Pattern is a creational design pattern that allows us to create new objects by cloning existing ones rather than creating them from scratch. This pattern provides a mechanism to copy the original object and modify it per our requirements after cloning is finished. The client that needs to clone the object does not need to know and have access to the private fields of the object being cloned – the pattern allows to hide the implementation details of the cloning process. The cloning process can create deep clones, in which the objects graph is cloned recursively – in such a case, the client does not need to know all classes that need to be cloned – the client invokes the cloning process on the first object, which then calls cloning process on all of its objects, and so on.
More on this pattern…
To read more on this and the other patterns, get “GoF Design Patterns Distilled” book from Amazon or Leanpub: