Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > standard practices for storing user settings

Reply
Thread Tools

standard practices for storing user settings

 
 
Brandon McCombs
Guest
Posts: n/a
 
      12-27-2006
I have built an application that currently stores user connection
settings in a binary file. Of course it takes a lot of work to add in an
extra parameter to be saved because I have to modify how the data is
written to and read from the binary file. I wanted to know what the
standard practice is for storing user settings. Should I be creating a
properties file when a user chooses to save his settings? Are they meant
to be used at the user level or the application level? Are there other
ways to do this same thing (besides using the windows registry)?

thanks
Brandon
 
Reply With Quote
 
 
 
 
Daniel Dyer
Guest
Posts: n/a
 
      12-27-2006
On Wed, 27 Dec 2006 23:48:43 -0000, Brandon McCombs <(E-Mail Removed)> wrote:

> I have built an application that currently stores user connection
> settings in a binary file. Of course it takes a lot of work to add in an
> extra parameter to be saved because I have to modify how the data is
> written to and read from the binary file. I wanted to know what the
> standard practice is for storing user settings. Should I be creating a
> properties file when a user chooses to save his settings? Are they meant
> to be used at the user level or the application level? Are there other
> ways to do this same thing (besides using the windows registry)?
>


Use the Preferences API
(http://java.sun.com/j2se/1.5.0/docs/...es/index.html).

If I remember correctly, it stores values in the registry on Windows and
in an XML file in the user's home directory on Linux/Solaris.

Dan.

--
Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      12-28-2006
Brandon McCombs <(E-Mail Removed)> writes:
>I wanted to know what the standard practice is for storing user
>settings.


One needs a per-user storage place as a starting point.
I believe, this is:

http://download.java.net/jdk7/docs/a...eferences.html

However, you do not have to store all data there, just
- for example - the name of the file oder database with the
actual user data. See also:

»user.home User's home directory«

http://download.java.net/jdk7/docs/a...getProperties()

>Should I be creating a properties file when a user chooses to
>save his settings?


Simple name-value pairs are sufficient for a surprisingly
large area of applications. Actually, every information can
be stored this way.

Other means include databases, XML-files or RDF-files. I am
using my custom format »Unotal«, which is like enriched
S-expressions.

>Are there other ways to do this same thing (besides using the
>windows registry)?


In Java, there does not have to be a »Windows registry«
within the runtime environment at all.

 
Reply With Quote
 
Ed
Guest
Posts: n/a
 
      12-28-2006

Brandon McCombs skrev:

> Of course it takes a lot of work to add in an
> extra parameter to be saved because I have to modify how the data is
> written to and read from the binary file.


Preferences, as already mentioned, are the way to go.

But even if you weren't using Preferences, even if you were writing the
name/value pairs to the File yourself, it's difficult to see why it
should take, "A lot of work," to add a parameter. Are you sure you're
handling your configuration parameters within your program efficiently?
When you add a parameter, you should make three changes to the code
(the details of saving the parameter shouldn't change whether you're
using Preferences or not):

i) The new parameter itself (usually a new class).
ii) The class the instanciates the parameter (even this can be avoided
if the paramter registers itself with a central parameter group).
iii) The user(s) of the parameter.

Specifically, there should be no new code for presenting this new
paramter to the user and allowing him/her to change it. If you're
introducing new presentation code for each new parameter, then
something's wrong. Possibly.

For example, see:
http://www.edmundkirwan.com/servlet/...rac-cs110.html

..ed

--

www.EdmundKirwan.com - Home of The Fractal Class Composition

 
Reply With Quote
 
Brandon McCombs
Guest
Posts: n/a
 
      12-28-2006
Stefan Ram wrote:
> Brandon McCombs <(E-Mail Removed)> writes:
>> I wanted to know what the standard practice is for storing user
>> settings.

>
> One needs a per-user storage place as a starting point.
> I believe, this is:
>
> http://download.java.net/jdk7/docs/a...eferences.html
>
> However, you do not have to store all data there, just
> - for example - the name of the file oder database with the
> actual user data. See also:
>
> »user.home User's home directory«
>
> http://download.java.net/jdk7/docs/a...getProperties()
>
>> Should I be creating a properties file when a user chooses to
>> save his settings?

>
> Simple name-value pairs are sufficient for a surprisingly
> large area of applications. Actually, every information can
> be stored this way.
>
> Other means include databases, XML-files or RDF-files. I am
> using my custom format »Unotal«, which is like enriched
> S-expressions.
>
>> Are there other ways to do this same thing (besides using the
>> windows registry)?

>
> In Java, there does not have to be a »Windows registry«
> within the runtime environment at all.
>



thanks guys. I'm already looking into the PReferences API and I like it
(haven't implemented any code yet though). thanks again
 
Reply With Quote
 
John Ersatznom
Guest
Posts: n/a
 
      12-29-2006
Stefan Ram wrote:
> Other means include databases, XML-files or RDF-files. I am
> using my custom format »Unotal«, which is like enriched
> S-expressions.


Tangential: what are S-expressions?
 
Reply With Quote
 
Alan Krueger
Guest
Posts: n/a
 
      12-30-2006
John Ersatznom wrote:
> Stefan Ram wrote:
>> Other means include databases, XML-files or RDF-files. I am
>> using my custom format »Unotal«, which is like enriched
>> S-expressions.

>
> Tangential: what are S-expressions?


http://theory.lcs.mit.edu/~rivest/sexp.txt

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Settings.settings file with settings for multiple regions donet programmer ASP .Net 3 11-20-2009 03:05 PM
User Images: Storing in Files VS Storing in Database Jonathan Wood ASP .Net 1 06-02-2008 05:56 PM
moving "my documents and settings\user\local settings\temp" FredHead Computer Support 11 01-17-2007 06:03 AM
storing pointer vs storing object toton C++ 11 10-13-2006 11:08 AM
Best practices for storing, archiving photos ProudMonkeyBiz Digital Photography 29 10-01-2005 08:08 PM



Advertisments