Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

Interesting question for preferences saving/restoring

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 18 Oct 2004 21:55 GMT
I have a large application; lots of forms, multiple dynamic DLLs, etc. I
also have, in the appliation, a general 'Preferences' class object (which is
in itself a separate DLL, and I just include a reference to it so I can
instantiate it at the beginning) which stores all my user preferences. I
serialize the data to and from an XML file, thereby saving and restoring the
user preferences with ease. I also have a Preferences form that the user can
select to modify certain preferences themselves, such as colors, etc. (I say
'certain' because I also save non-browsable preference such as window
location, window size, etc)

I have basically two options to work with the preferences class in my
application: (a) When I load the application, instantiate the preferences
class, load it from the XML file, then keep that class in memory,
referencing the properties as needed. I would also need to 'pass' a
reference to this class around since I do load and use dynamic DLLs. Or (b)
Everytime I need to reference or save a preference, I would simply reload
the class from the XML file, make my modification (or read the data), then,
if needed, re-save the file back out to XML.

The advantages of option A is that, in theory, I only have to read the file
once and then write it out once (I say 'in theory' becuase, when the user
loads the preferences panel, I should save anything that had been modified
up to this point, then re-save the preferences once the user closes the
preferences panel so that things are saved properly). However, it can be a
pain passing the references around to everything, especially since I use
dynamically loaded DLLs. Option B has the advantage in that whenever I
deserialize the preferences class I -KNOW- that I have the latest and
greatest preferences settings. The disadvantage is that I have to read and
write (serialize and deserialize) it every time I want to access or store
information into the class object; and I don't know what kind of performance
hit it will take doing this all the time.

Now the question is: What do you think would be the best method of doing
this? A or B? Or is there another way? I've tried to do a combination of the
two, but it is ending up being very complicated trying to keep things in
sync. I can go either way but was just wondering what everyone thought might
be a better (and more OOP) method of doing it.

Thanks in advance.

Tom
Brad Shook - 19 Oct 2004 16:34 GMT
Option A is probably the way I would go. However another downside to that is
the more you store in memory the more likely your application will run out
of memory. But when a user loads a form it should be quick and if you have
to read the file to determine color of objects and display names, etc. it
will increase the form's loading time. It might not be a big deal but if you
also have to load data every millisecond counts.

Brad Shook
> I have a large application; lots of forms, multiple dynamic DLLs, etc. I
> also have, in the appliation, a general 'Preferences' class object (which is
[quoted text clipped - 37 lines]
>
> Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.