Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Persisting preferences - the best way? 2

Status
Not open for further replies.

SpankySpanky

Programmer
May 25, 2005
21
AU
Hi All

I am currently designing my first major application in VB.NET and I want to get it right first time. I would like to know what the industry standard method is for persisting preference settings and form positions etc.

For example, I have a number of pages of user options / preferences which I would like to store each time they are changed, as well as keep the users' selection of form positions, sizes, etc. Perhaps saving them as a profile for each user as a file might be useful, instead of packing them into the registry. There will probably be a number of settings for different things scattered throughout the whole project, and somehow handling them as a set would be nice.

Is there some standard, neat, object oriented way of storing them and loading them back in at runtime?
Does each one have to be stored and loaded by writing code for each or is there something available to handle it automatically when I create new forms and options?

Thanks for any advice.

 
I am currently designing my first major application in VB.NET and I want to get it right first time.
Hmm... better ditch the VB and use C# instead, then... [smile]


But seriously, you are right to want to keep them all in one place - it will make the 'Options' dialog much easier to manage. Unfortunately, there isn't really a right answer - if it's web based, you might want to keep them in a database on the server, if it's a standalone desktop app then you might want to save them in an XML file locally. You might consider using an abstract superclass or an interface on your persistence-managing object, to allow you to switch between different implementations that you can use depending on the situation, while still keeping the same signatures and behaviours.

This will allow you to reserve judgement on the most appropriate method until you have a better idea about the application.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
I would have each User associated with a UserProfile object. The UserProfile object will contain ViewSettings.

You can then pass the ViewSettings object into the instance of the form or page on loadtime. When the page loads it will use the ViewSettings to manipulate it's display to the user Preferences.
 
<better ditch the VB and use C# instead, then

Well, whenever I need to overload my operators or write unsafe code, I'm the first one in line to use C#. Until then, I prefer to write in VB6 and use the migration wizard.........

:p

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top