Deep copy alternatives

B

bg_ie

Hi there,

In my application I have a Settings class which has two objects,
userSettings and defaultSettings. When the application starts, I use a
deep copy to set-up userSettings with the values found in
defaultSettings. This was an akward process, as the Settings class
contains many Lists, some of which contain Lists themselves, and so
on. As the program executes, the userSettings object is updated. Then
when the program is exited, I use a deep comparison of my two objects
to check if their constituent values are equal. If not, the user is
asked to save their own version of the settings.

Is this a good approach and if not, how would you go about doing this?
I took some time to write the deep functions and I have yet to test
them fully. A lazy, but less bug prone approach perhaps to the deep
copy issue would be to deserialize defaultSettings and serialize the
result to userSettings...

Thanks for your help,

Barry.
 
L

Larry Smith

In my application I have a Settings class which has two objects,
userSettings and defaultSettings. When the application starts, I use a
deep copy to set-up userSettings with the values found in
defaultSettings. This was an akward process, as the Settings class
contains many Lists, some of which contain Lists themselves, and so
on. As the program executes, the userSettings object is updated. Then
when the program is exited, I use a deep comparison of my two objects
to check if their constituent values are equal. If not, the user is
asked to save their own version of the settings.

Is this a good approach and if not, how would you go about doing this?
I took some time to write the deep functions and I have yet to test
them fully. A lazy, but less bug prone approach perhaps to the deep
copy issue would be to deserialize defaultSettings and serialize the
result to userSettings...

Are you rolling your own or relying on strongly-typed settings which are
easily set up in the (VS 2005) IDE (all based on the
"ApplicationSettingsBase" class). Right click your project's name in
Solutions Explorer, select "Properties" and click the "Settings" tab on the
left. There's a link at the top called "Learn more about application
settings" to get you started. Also see the following MSFT blog. I've dealt
with the author before and he's very experienced.

http://blogs.msdn.com/rprabhu/articles/433979.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top