[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copyObject: deep or shallow copy?



On Fri, 06 Apr 2001, Nathan Eric Probst wrote:
> > > Does Database.copyObject() to a deep copy or a shallow copy?
> > deep. (excluding dependent database objects of course)
> >
> 
> why excluding dependent database objects?  couldn't it to a copyObject
> on those
> recursively
of course it could, I'm just not sure if all programmers would expect such
behaviour from a copyObject() method. copyTree() or copyGraph() would be better
for such behaviour.

> 
> >
> > >
> > > By way of example:
> > >
> > > Say I have a three-layer deep graph of database objects that I want to use as a
> 
>                                            ^^^^^^^^^^^^^^^^
shit. sorry!

> 
> >
> > > template.  This objects are ititialized and maintained in a "blank" state.  I
> > > want to do a deep copy of this graph when creating a new instance of an object
> > > which contains this graph, but I don't want to get references (and thereby
> > > modify) the original "blank" template objects?
> > is this graph made of database or ordinary objects?
> >
> 
> database objects:  ProductType -> AttributeGroup -> Attribute.
> 
> >
> > >
> > > Does this make sense?  Am I babbling?  I don't know...
> > >
> > > Also, I seem to recall someone saying that copyObject had some performance
> > > advantages.  Is this correct?
> > advantages over what?
> >
> 
> over createObject.
depends on the complexity of the init procedure. If there are a lot of things
to do to init the new object,then copying might be faster indeed.


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com