Thomas said:
I repeat myself: Calculate e.g. a hash, and use the hash as a key
instead. Or consider not abusing a preference mechanism for object
persistance.
I'd like to use a hashCode mechanism, but I am not sure how.
The getClass.hasCode() method returns different value for
each run. I guess computing a checksum might be a possible
approach?
And please explain why you consider this "abusing" the
preference mechanism; I do like to improve my skills on the
subject. I for instance regard a window position and size as
a "user preference". I store this setting using java Preferences
with keys like "width", "height". Then:
o As I have many window types to consider I prefix the settings
with the window class name.
o As there may be several windows of the same type I postfix
the setting with an integer index.
o As there are different users to my system, I prefix the setting
with the user name.
o As each user can have named sessions, I prefix the setting
with the session name.
o As I have different executables within the same java
package tree, I prefix the setting with the executable class.
As you can see, the keys becomes quite verbose, but I can't
see that this is "abuse" still. Poweruse maybe...
Thanks!