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 1 1628
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
"Tom" <to*@nospam.com > wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl... 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jacob H |
last post by:
Hello list...
I'm developing an adventure game in Python (which of course is lots of
fun). One of the features is the ability to save games and restore the
saves later. I'm using the pickle module to implement this. Capturing
current program state and neatly replacing it later is proving to be
trickier than I first imagined, so I'm here to ask for a little
direction from wiser minds than mine!
When my program initializes, each game...
|
by: Brian Wallis |
last post by:
This may be a FAQ,but I cannot find it.
I want to save user preferences, window sizes, recently opened file names,
etc for a python application and I am looking for a package that does this
in a way that is portable across unix/linux and windows (and mac would be
nice as well).
Is there a 'standard' package for doing this in python?
thanks,
|
by: Adam J. Schaff |
last post by:
OK, there are billions of posts on dotnet newsgroups about this, and I have
read half of them, but I'm still a little confused. First I'll say what I
think I've learned and anyone can correct me if I'm off target.
1. User preferences should be saved to the UserAppDataPath.
2. They should be saved as an XML file.
3. Serialization is a handy technology for going about this, since you can
simply store all your preferences in an object and...
|
by: Mountain Bikn' Guy |
last post by:
What is the current preferred way to save user preferences in dotnet? Is the
registry the right place to do this? Can anyone recommend a good article (or
book) for this topic? Thanks.
|
by: Tom |
last post by:
I am planning on adding a Preferences form to my application and using the
Property Grid to display the preferences to the user. What do you think
would be the best way to save these preferences out to an XML file? Use the
CAB (Configuration Application Block)? Save the preferences in a class
object and serialize them out the the XML file? Write them out directly to
the XML file? Other ways???
Just want to get some thoughts together......
| |
by: Tom |
last post by:
I am planning on adding a Preferences form to my application and using the
Property Grid to display the preferences to the user. What do you think
would be the best way to save these preferences out to an XML file? Use the
CAB (Configuration Application Block)? Save the preferences in a class
object and serialize them out the the XML file? Write them out directly to
the XML file? Other ways???
Just want to get some thoughts together......
|
by: Marcus Kwok |
last post by:
How do you save the formatting options for a stream? In the program
below, notice that when I define my operator<<() for the custom type, it
permanently changes the output format of the stream:
#include <iostream>
#include <iomanip>
struct Data {
double d;
};
|
by: sonic |
last post by:
so, profile provider is a way to save application preferenes for each
user. the profile can be replaced to provide a different persistance
layer, and/or schema, but what about tweaking it to work in page level,
to save preferences for all controls on each page for example.
in a application with 100's of sites, containing many of the same
controls, i'd like to be able to persist different states of controls
depending on the page, and also...
|
by: Tal Shachar |
last post by:
Hi,
I have a windows application that needs to save some user preferences to an
xml and to load it on the next application run.
Saving the preferences is done per user.
I know that there is a way of saving it to some path under "Documents and
Settings/UserName/...." , but I don't know the correct approach (e.g. path
naming convention, how to preserve this per user, etc.)
I can use all the assistance I can get (code snippets and some...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |