Cloning an object

Posted by jmls on 29-Jul-2010 01:41

Is there any way to copy or clone an object without having to specify each property line by line ?

Julian

All Replies

Posted by bdearborn on 29-Jul-2010 01:45

Hi,

I am currently out of the office with limited access to voice mail and

email and will be returning on August 2nd. If you need immediate

assistance please contact Jim Stein at jstein@cornerstar.com.

Thanks,

Bryn Dearborn

503-805-8598

--

Bryn Dearborn

503-928-8115 (Work)

503-805-8598 (Cell)

www.cornerstar.com

Posted by Admin on 29-Jul-2010 02:00

Is there any way to copy or clone an object without having to specify each property line by line ?

 

Depends on the implementation of the Clone() method (optional).

Which object are you seeking for? For your own objects you should implement the Clone() method yourself.

Posted by jmls on 29-Jul-2010 04:35

I was hoping that you wouldn't say that. I want to create another

instance of an existing object without having to write all the assigns

by myself

Posted by Admin on 29-Jul-2010 04:45

I was hoping that you wouldn't say that. I want to create another

instance of an existing object without having to write all the assigns

by myself

No sorry that isn't possible - and probably not desirably. Just duplicating an object would duplicate encapsulation. The class needs to decide the actual state of the copy - or might not even like duplicate (singletons).

Posted by Thomas Mercer-Hursh on 29-Jul-2010 11:35

Vote for the enhancements discussed here http://communities.progress.com/pcom/thread/27156?tstart=0

WRITE-XML on the source object and a READ-XML to create a new object would be the perfect way to do a clone.

Doesn't help you now, of course.  Program generators are good at this sort of thing.

This thread is closed