puzzle about prototype pattern

is prototype just use clone substitute the "new" operation? but client must know about manager and concrete products and initial manager with products he or she wants,so what's use of this manager and clone-- if client want to get product, he or she must "new" it and then clone it .

in my view the initial operations shoudble be place into manager.and both client procedure and manager dependent on an external file and dynamicaly load the product.then clone operation deserve it's existing.

thanks for any help.

[535 byte] By [dxuranusa] at [2007-10-2 10:08:10]
# 1

> is prototype just use clone substitute the "new"

> operation? but client must know about manager and

> concrete products and initial manager with products

> he or she wants,so what's use of this manager and

> clone-- if client want to get product, he or she must

> "new" it and then clone it .

> in my view the initial operations shoudble be place

> into manager.and both client procedure and manager

> dependent on an external file and dynamicaly load the

> product.then clone operation deserve it's existing.

> thanks for any help.

I must first admit that I'm not too familiar with the Prototype pattern and I'm finding it very hard to figure out what you're asking, so keep that in mind.

As I understand it the point of the Prototype pattern is to allow an object to clone itself because the client may not have knowledge of how to create/copy an object. The client invoking clone() does not have to "new" it becuase the client may have simply received it from somewhere else and may have no knowledge of the implementation. For example, my ImageCanvas must use an ImageRenderer to render the image but that ImageRenderer gets passed to it and could be any implementation. It needs to be able to create a copy of the ImageRenderer but has no idea what concrete implementation it may have been given and no way of creating a copy except for the use of clone() to ask it to create a copy of itself and return it.

kablaira at 2007-7-13 1:26:16 > top of Java-index,Other Topics,Patterns & OO Design...