Prototype Pattern

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

See: DesignPatterns


http://rampages.onramp.net/~huston/dp/prototype.html

http://wiki.cs.uiuc.edu/patternStories/PrototypePattern

http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html

If I create an object with certain properties, then use this to create another object (by passing it to a constructor) which will be initialised with those properties, this would seem to be a Prototype, but this is a little different from the GoF pattern - any thoughts? --- DannyAyers

Looks like a CopyConstructor to me. --- LairdNelson

You would lose the advantage of polymorphism that the GoF formulation of the Prototype pattern gives you. -- NatPryce


Exactly... Prototyping is all about creating a replica of myself. I don't know my exact type, i.e. polymorphism. But I can duplicate myself when somebody else needs a duplicate of me, and he doesn't care about my type (position in the inheritance tree). --Praveen
Could it be that the StaplePattern could be included under this title?
The use case I think think of while using this pattern is to make certain properties of an object immutable while creating new object. The immutable properties can be changed only in prototype. Thus making the object created effectively immutable. --- ShripadAgashe?


Personally, I think prototypes are useful for GUIs and stuff, allowing inheritance of traits from parent graphic entities. What is the general opinion on this matter?
CategoryPattern | CategoryCreationalPatterns

EditText of this page (last edited January 20, 2014) or FindPage with title or text search