A conceptual question... I have a XML configuration file used to set various behaviours in an application (colours, supressing help prompts etc). On starting the application, the XML is deserialized into memory, in a class whose structure matches the XML file's structure.
For info, the application is a C# WinForms GUI application - though this question I think is really applicable to any OO language.
I'd like to implement a set of GUI forms to edit this config file, and just looking for some 'best-practice' guidance.
I've laid out the config editor forms using a tree view and panel forms that dynamically show/hide as you navigate through the tree (just like Visual Studio's Tools > Options menu).
The pages contain tick boxes, path text boxes etc.
So the crux of the question - if a user starts editing the options, unchecking boxes, changing file paths etc - I don't want to edit the actual config object yet, because the user might select 'Cancel', instead of 'Ok' on the window.
As such, I'm trying to decide on the appropriate design for this - is this a sensible use case to take a deep copy of the config upon loading (call this the 'local' copy), then if the user hits 'Ok' on the window, the local copy is written back into the main config, else it's just discarded.
Or, is there a better solution to this sort of use case?