language agnostic - Does a deep copy operation recursively copies subvariables which it doesn't own? -


Looking at the object that has no variable which it does not own itself; That is, the variable is created by instead of what would be a deep copy operation variable or just link to it?

I like that you are making the role of structure and aggregation here in the middle. Deep copy

I will say to go against the second answer: No, no item should not be deep-copying of any other thing which is not its own.

A deep copy of an object (at least initially) is similar to the original. If a deep copy is made of a reference that was not owned by the origin, then it reveals the question that what is the owner of a new copy, if the owner of the clone, then it will not be the same as the original object. It will be an object like the original, except that it is the owner of the context of one of its consolidated members. This will definitely cause chaos. If the clone is not owned, who does it?

This problem of ownership in non-garbled collective languages ​​is particularly important, but it also creates problems with the garbage collector. For example, if an object is cloned to allow unchanged changes, then is there permission to make changes to other objects in this context? If change was not allowed, then there was no reason to copy it deeply. If changes are allowed, how will these changes be made, because the object being modified is not controlled by this referred object? Of course, a mechanism can be prepared for this, but it will mean the clone object is crossing its responsibilities, and this program will be a maintenance nightmare.

For a deep copying action involving exclusive things that are infinite (or at least too much) copy operation problems, assume that an object is a part of the collection, and it seems that the object is to be stored Reference is required. A naive-deep-copy operation on that object will then create a new copy of the archive and a new copy of its members. Even assuming that we avoid the problem of endless repetition, and consistent with all contexts between this new set of objects, it is still excessive for most purposes, and in those cases where a new The collection is desired, it will not make much sense.

I think a deep-copy contains only proprietary things, as you suggest, for most purposes The only sensible approach.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -