Talk:Computer Science Design Patterns/Prototype

If I have an implementation that may be good enough to add to the prototype implementation list. If so, how would this be added?
I'm teaching myself some design patters and have what I think may be a workable python implementation of the prototype design pattern. I didn't see a way to edit the page, so figured I would drop it off here. There are probably some NOOB aspects to this, but I've only been programming professionally for 6 months, and I had to stop writing code altogether for 6 months after that due to some traveling so there are likely some obvious refactorings you can spot right off the bat, or maybe I have something that works, but not the way I intended because I'm not 100% sure what's going on behind the scenes...please be gentle...

I think the strength of this decorator approach for prototyping is how simple it is client-side. Whether I did it 100% right, the fact that all the client needs to do is throw "@Prototype" on top of the class definition and then they can call "Clone" on any object created with that definition and assign the result to a variable...and that's it...

Output:

Creating A

Cloning A to B

A and B somevars

0

0

Changing A somevar to 10...

A and B somevars

10

0

Creating another kind of class as C

Cloning C to D

Changing C somevar to 100

C and D somevars

100

50

Irishfarmer01 (discuss • contribs) 03:35, 7 February 2014 (UTC)


 * It seems to be the implementation of the Prototype design pattern. I have read the code. I don't know all the functions in Python but the code is logical. I have added your code. You say that you don't manage to put this on the page. I don't know what has embarrassed you. The mechanism should be the same for the page and for this talk page. The only issue is that we can't edit a single section, we have to edit the whole page. This is due to the template of the page. Ftiercel (discuss • contribs) 20:14, 9 February 2014 (UTC)

the client source code use a tempotype should we read prototype ?
after a quickly read of exemple source code (c++ and java): the 'client source code' use a tempotype should we read prototype ?
 * c++ source code :
 * I renamed the variable temporaryPrototype. Every variable name should be explicit. This variable could have been named with anything because we are in the client code. It's not the design pattern implementation. I admit the term prototype in temporaryPrototype is confusing as this object is not the prototype of any other object. I have tested the code.

the 'new' instruction is never used ?
 * java source code :
 * Yes, it is used at line 6, PrototypeTest class. Ftiercel (discuss • contribs) 20:27, 27 February 2014 (UTC)