Talk:Prototype pattern
From Wikipedia, the free encyclopedia
What is GOF (references to an unidentified book)? Tom Peters 09:59, 18 January 2006 (UTC)
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
The example link is dead ... Please use link http://wwwswt.informatik.uni-rostock.de/deutsch/Lehre/Uebung/Beispiele/PatternExamples/patexamples.htm
The example link is dead ... Please use link http://wwwswt.informatik.uni-rostock.de/deutsch/Lehre/Uebung/Beispiele/PatternExamples/patexamples.htm
62.39.121.226 13:31, 7 October 2005 (UTC)Rajiv
I wonder why the GoF authors say that Prototype is more complexe than Factory Method which relies on a hierarchy parallel to the Product hierarchy! I think there is a confusion between several problems that the pattern solves. First, Prototype solves the same problem as Factory Method, namely creating instances of classes without naming them. Second, it can be used to build objects faster or more easily by copying already built ones. There certainely are other uses for this pattern.
If the goal is to decouple clients from the classes to instantiate then I do not see why it would be more complex than Factory Method: on the contrary it is much simpler (no parallel hierarchy). The clone method is in fact a misnomer is this case: you do not need to clone a prototype p but simply want a new object of the same (dynamic) type as p. MikalZiane 13:05, 26 June 2006 (UTC)