Object copy

from Wikipedia, the free encyclopedia

In software technology, an object copy , also known as a clone , is an exact copy of an object , i.e. an instance of an abstract data type . The type of the object must be retained and all attribute values ​​must be copied into the target object. A basic distinction is made between

  • a shallow copy (shallow copy) , in which the clone does not actually receives copies of the attributes, but only references to the attributes of the original object, and
  • a deep copy (deep copy) are actually copied themselves deep in all attributes.

A lazy copy guarantees a deep copy, as it were, that changes to attributes do not affect the copied object, but actual copies of the attributes are only made when necessary. When creating the object copy, all attributes are initially only copied via a shallow copy; as soon as the first write access occurs to an attribute that could violate that guarantee, a deep copy is performed.

Web links