views:

90

answers:

8

What is the widely-accepted way to store interface choices, such as 'Do not show this message again' settings, and any other interface-specific choices of the user? Registry? Settings files? I can also store them in a database, since my program already has access to one.

EDITS My current program is local, however in the future I would like to make it web-based.

+2  A: 

if its a Web-related Environment: depends on how long you want them to stay. If there is a member registration within a database it would totally make sense to save it in the database. Else you could just save it as a cookie or ip/setting in a database.

Thomas Strobl
+7  A: 

A non-web-based program:

I wouldn't use a database. What happens if you decide to switch the database? Now you have to migrate the user data. What happens if they uninstall?

In Windows, settings files in the user's AppData folder are appropriate. It's also acceptable to not delete these on uninstall, so the settings will persist across that. I would shy away from the registry for user settings. That area is more appropriate for system settings.

There's a similar area in *nix systems, but I'm not sure off the top of my head. It's been too long.


A web-based program with local settings:

Cookies are pretty much the only computer-specific option for a web-based program. IP-based filters are a bad idea, since most consumer internet options will rotate IPs once a day to once a week. You could MAC filter, but that would involve using raw sockets to get the MAC address. And even then, you will probably end up with the address of a router, not a computer. Meaning two people on a single router would get the same settings.


A web-based program with global settings:

Your program should query a web service for this. The service is then free to implement it in whichever way is best at the time. A database is fitting in this scenario, as it's likely that your user data already exists and is keyed therein, providing an easy way to associate data with particular users.

jdmichal
On "It's also acceptable to not delete these on uninstall" .... But it's not a bad idea to provide an option in the Uninstall routine, particularly if it's a large amount of data. As a courtesy to the user, if nothing else.
Rob
@Rob Excellent point.
jdmichal
@jdmichal - I've also just thought of the fact that the user could be uninstalling to try and get rid of corrupted settings/configuration that prevent them using the application (we've all been there, I'm sure!); another reason to make removal an option =)
Rob
+2  A: 

Assuming you mean on a Windows application, the .NET Application Settings feature uses the filesystem by default (though you can use the registry or anything else, as it's pluggable).

Graham Lee
+1  A: 

It is typically handled by Windows via API. MSDN article on How to: Program Exception Message Box explains how to do it with .NET. According to the article, the exception is stored in the registry if you want to store the decision permanently in that manner.

You can also store the decision in a custom XML config file, use your Application Settings file to store it, or in a database. It is up to you on the simplest implementation and least headaches.

The new recommended way is to store it under the User's Application Data directory. See Data and Settings Management at Technet.

0A0D
+2  A: 

You can store them where ever it's most convenient.

In the database - if the database is remote you don't need access to the local file store, but it does mean that if the connection's not there you can't access the preferences.

In the registry - you need to make sure that you are using the CURRENT_USER area so that the user can actually write to it. Windows specific.

In a file - storing locally means that you're not relying on the connection to the database, but again you need to make sure that the user has rights to the folder you want to save the file to. C#/.NET provide classes for reading and writing user settings files so this is probably your best choice.

ChrisF
+1  A: 

On Windows, the "new" way is to store the configurations in the user's "App-Data" (CSIDL_APPDATA) folder.

Max
+1  A: 

My recommendation would be a file (INI, Settings, etc.) stored in the application installation, or in App_Data. Storing it in the Registry is definitely a popular way to do it, but cleaning it up when it's no longer relevant doesn't seem to be so popular. So if you decide to use the registry, make an effort to clean up after yourself if needed (uninstall, registry entry structure change, etc.)

Superstringcheese
+1  A: 

I have stored individual user settings in the database for a WinfForms application that used a location specific database. This worked nice because as users logged in on different client machines, their display settings moved along with them.

dretzlaff17