Timeline for How to safely copy an object?
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 5, 2014 at 1:07 | comment | added | david.pfx | @Prog: Nested value objects could need deep/nested copy, but otherwise that sounds about right. | |
Jun 5, 2014 at 0:02 | comment | added | Aviv Cohn | Here are the main points I gather from your answer: 1- 'Value objects' should always be copied accurately. 2- 'Identity objects' (objects with actual functionality) should rarely be copied. If an identity object needs to be copied, possibly bad design in the first place led to this. 3- If I do need to copy an identity object - there is no special rule or technique for this. It's just 'case-by-case' - I should treat each time this happens individually: figure out what's the best way to do a deep-copy for the object in this specific situation. Is all of this correct? | |
Jun 2, 2014 at 10:02 | comment | added | david.pfx | @prog: Not always, but certainly requires extra care. See edit. | |
Jun 2, 2014 at 10:01 | history | edited | david.pfx | CC BY-SA 3.0 |
Added response to comment
|
Jun 2, 2014 at 9:56 | comment | added | david.pfx | @RobertHarvey: Fair point. See edit. | |
Jun 2, 2014 at 9:55 | history | edited | david.pfx | CC BY-SA 3.0 |
Added response to comment
|
Jun 2, 2014 at 9:50 | comment | added | Aviv Cohn | David - so if in an app of mine I have an 'identity' object that has to be copied - probably bad design? | |
Jun 2, 2014 at 6:26 | comment | added | Robert Harvey | True value objects seldom (if ever) contain references to other objects. The absence of references is one of the things that characterizes them as value types. | |
Jun 2, 2014 at 5:12 | history | answered | david.pfx | CC BY-SA 3.0 |