Timeline for Is a preferences editing GUI a good use case of a object deep copy?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 19, 2023 at 19:49 | comment | added | Filip Milovanović | @jwilo - "I get the feeling that deep copies are somewhat taboo based on what I've read" - nah, not a taboo; if the objects just form a simple hierarchical data structure that branches in a relatively straightforward way and doesn't have any tricky joins (two objects having the same child) or loops (single or multi-level circular references) within itself, or references to some large chunk of data that you don't want copied, then it's not really a problem. It's with those tricky cases where you have to be careful what you want to copy, where to stop when traversing the graph, etc. | |
Nov 19, 2023 at 19:36 | comment | added | mountainred | To make this design somewhat user friendly, I've create a copy constructor in my configuration class, and an 'overwrite' method that takes an instance of it's own class in as an argument, and copies from this too. So other than the 'pain' of ensuring this constructor and method contain all the members, it works nicely. | |
Nov 19, 2023 at 19:34 | vote | accept | mountainred | ||
Nov 19, 2023 at 19:34 | comment | added | mountainred | Thanks @J_H, being relatively new to OO languages I get the feeling that deep copies are somewhat taboo based on what I've read, so it's good to have somebody agree this is an appropriate use case! | |
Nov 19, 2023 at 19:17 | history | answered | J_H | CC BY-SA 4.0 |