Talk:Prototype pattern

This is an old revision of this page, as edited by 203.90.124.178 (talk) at 06:44, 18 June 2004. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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 a replica of myself .I don't know what i'm.ie polymorphism..But i can duplicate myself when some body else needs a duplicate of me and he don't care about my type (Hierarchy in the inheritance tree). --Praveen
By using Copy Constructor, this design pattern can be applied. But in C++ copy constructor is default property means you not need to declare it explicitly.

But in other language may be copy constructor had to declare to provide such facility. In this case if some derived class in tree doesn't declare it then this pattern will fail for that hierarchy tree. That may be happen since OO language has the facility of reusability. So to keep pattern language independent I suggest declare the 'Clone' kind function as a pure virtual. That will force each drive class to provide Prototype facility. ---------Akash Gupta

Hey guys, moved the discussion here. If you have any other questions or things to discuss, place it here instead of in the article itself. : ) -Frecklefoot