standard practices for storing user settings

Discussion in 'Java' started by Brandon McCombs, Dec 27, 2006.

  1. 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
    Brandon McCombs, Dec 27, 2006
    #1
    1. Advertising

  2. Brandon McCombs

    Daniel Dyer Guest

    On Wed, 27 Dec 2006 23:48:43 -0000, Brandon McCombs <> 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/guide/preferences/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
    Daniel Dyer, Dec 27, 2006
    #2
    1. Advertising

  3. Brandon McCombs

    Stefan Ram Guest

    Brandon McCombs <> 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/api/java/util/prefs/Preferences.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/api/java/lang/System.html#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.
    Stefan Ram, Dec 28, 2006
    #3
  4. Brandon McCombs

    Ed Guest

    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/fractal/cs1/frac-cs110.html

    ..ed

    --

    www.EdmundKirwan.com - Home of The Fractal Class Composition
    Ed, Dec 28, 2006
    #4
  5. Stefan Ram wrote:
    > Brandon McCombs <> 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/api/java/util/prefs/Preferences.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/api/java/lang/System.html#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
    Brandon McCombs, Dec 28, 2006
    #5
  6. 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?
    John Ersatznom, Dec 29, 2006
    #6
  7. Brandon McCombs

    Alan Krueger Guest

    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
    Alan Krueger, Dec 30, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Siegfried Heintze
    Replies:
    0
    Views:
    2,255
    Siegfried Heintze
    Oct 24, 2005
  2. toton
    Replies:
    11
    Views:
    695
    toton
    Oct 13, 2006
  3. Jonathan Wood
    Replies:
    1
    Views:
    498
    Jonathan Wood
    Jun 2, 2008
  4. leeanne
    Replies:
    0
    Views:
    1,839
    leeanne
    Sep 24, 2008
  5. donet programmer
    Replies:
    3
    Views:
    1,515
    Gregory A. Beamer
    Nov 20, 2009
Loading...

Share This Page