7 Replies - 710 Views - Last Post: 03 June 2011 - 11:06 AM Rate Topic: -----

#1 lando786  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 29
  • Joined: 27-April 11

Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 05:09 AM

What would be the quickest way to have save-able settings on an application.What I mean by settings is for example I have a simulation application (which by the way is not what I intend to be doing but seems easier for demonstration purposes)and I want the user to be able to SAVE some defaults for the application. For demo purposes lets say "default car speed" and every time the application opens it automatically runs said car at set speed, giving the end-user the ability to change the default speed to another value.

So far I have thought of using a txt or ini file using the code
string MyFolder = Path.GetDirectoryName(Application.ExecutablePath);

And just setting the config file to

string config = MyFolder + "config.ini" 


Now this application may or may not be installed on several PCs, so I also thought of using a centralized table on an SQL server. Is that just overkill for this application? I mean, I know the performance will degrade a lot since it will have to query all the settings.

Is there an alternative solution where I can enable saving settings while at the same time making them universal for the application regardless of what machine it is installed on? My concern is that say X user installs it on one PC, then goes to another PC and installs it, that he/she may forget to re-change the default settings and not get the desired results.

Any and all help would be greatly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Quickest most effective way to have a "Settings" section on an

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5441
  • View blog
  • Posts: 11,676
  • Joined: 02-June 10

Re: Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 06:00 AM

If you follow the basic but important idea to separate the GUI from the data it helps.
If you have a class just for the values you can then serialize that class.
Using your example for car speed you would have a property for the car speed, within the PreferencesObject.
Then your form makes an instance of the PreferenceObject by deserializing it, filling in the GUI while you're at it.
Was This Post Helpful? 0
  • +
  • -

#3 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4438
  • View blog
  • Posts: 7,720
  • Joined: 08-June 10

Re: Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 07:18 AM

Quote

My concern is that say X user installs it on one PC, then goes to another PC and installs it, that he/she may forget to re-change the default settings and not get the desired results.


If you want your settings to follow the user, then you have to have some sort of central DB that all the instances log into. You need to define what properties you want to set, then create your table(s) for it. If they're going to be specific to a user, you'll also need some way to track who's settings belongs to whom. For instance, you could make your own login system, if you want. Or, if you're all on an Active Directory network, you can get their windows login name and use that.




If you don't need the settings to follow the user, there's already a built in feature. The Settings.settings file. You can add settings here (and they're stored in the App.config). It has two types of settings. Application settings are unchangeable by the program, and are the same for all users. User settings are able to be changed and saved, and are distinct for each user.

Here's an article on using the Settings.settings file:

http://msdn.microsof...9(v=vs.80).aspx
Was This Post Helpful? 2
  • +
  • -

#4 Jeff H  Icon User is offline

  • D.I.C Regular

Reputation: 112
  • View blog
  • Posts: 307
  • Joined: 30-January 11

Re: Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 07:24 AM

Probably wait and see if tlhIn`toq or Curtis Rutland or someone with expirence replies, but forget speed and code what is the easiest to read and maintain.

Then once you test your application see if there are performance issues.(Of course considereing performance is not huge aspect of program where milliseconds are make or break).
Was This Post Helpful? 2
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4438
  • View blog
  • Posts: 7,720
  • Joined: 08-June 10

Re: Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 07:28 AM

Quote

Probably wait and see if tlhIn`toq or Curtis Rutland...replies


:D Look above your post.
Was This Post Helpful? 0
  • +
  • -

#6 ragingben  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 170
  • View blog
  • Posts: 637
  • Joined: 07-October 08

Re: Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 08:07 AM

View PostJeff H, on 03 June 2011 - 03:24 PM, said:

Probably wait and see if tlhIn`toq or Curtis Rutland or someone with expirence replies...

Kiss ass :)

View PostJeff H, on 03 June 2011 - 03:24 PM, said:

but forget speed and code what is the easiest to read and maintain.

Exactly. This should always be the priority, providing you are talking about speed in terms of coding time, and not in terms of runtime efficency
Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4438
  • View blog
  • Posts: 7,720
  • Joined: 08-June 10

Re: Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 08:14 AM

Actually, both. Premature optimization has caused more problems than it's solved. I'm not saying to use the slowest algorithms you can think of, but don't chase your tail on optimizing something before you know if it's even going to be a problem.
Was This Post Helpful? 1
  • +
  • -

#8 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Quickest most effective way to have a "Settings" section on an

Posted 03 June 2011 - 11:06 AM

I made this video last year, check it out.


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1