Object copy

An object copy, and clone in software engineering is an exact copy of an object, ie an instance of an abstract data type. The type of the object must be maintained, and it must all attribute values ​​are copied to the target object. A distinction is made between

  • A shallow copy (shallow copy), in which the clone is not actually copies of the attributes are obtained but only references to the attributes of the original object and
  • A deep copy (deep copy), in which all the attributes are actually in turn copied deep.

A lazy copy, as it guarantees a deep copy that do not affect changes to attributes on the copied object, actual copies of the attributes take place, however only when necessary. When you create the object copy all attributes are copied only a shallow copy; soon as the first write access occurs to an attribute which could hurt those guarantee a deep copy is performed.

612887
de