|
|
|||||||
|
I have several counter-arguments: (a) you say Quote: That is not always true. I may use a .properties classpath resource to contain some application defaults that I, the author of the application, may want to change in the future releases and I don't want them hardcoded in Java. The user won't even know that I have such a resource. The JDK itself comes with a ton of property files like that (just look under <jdk dir> for anything that matches *.properties) and nobody seems to be complaining about that. (b) you say Quote: Ok, now let's say that you do want user-editable properties. But I don't follow you connection from editable properties to them necessarily being loaded as java.io.Files. What if you told the user to edit a .properties file located, say, in <jre dir>\classes -- is that really hard? You can load this as a classpath resource and the changes will be picked up on the next JVM restart. (c) finally, there are tons of resources that the user might know about but will never have to edit. For example, let's say your application can parse user XML files written to a certain (well-known) XML schema. You can load the .xsd schema definition as a classloader resource, can't you? The user never has to edit that. Or as another example, instead of hardcoding all label/frame/etc titles in you Swing code, why not put them in a classpath .properties definition? This way you separate your visual content from the actual implementation. You can later localize it or fix typos by merely editing the non-compilable resource and again the user never touches such properties. Or if not text labels, consider .gif icon images instead: why do you expect the user to ever want to edit them? Surely you can load them as a classloader resource as well. A Java application of any reasonable level of complexity will have several such resources that are best loaded via classloaders. And for properties that are specific to an individual user's experiences (e.g., the size of his/her Swing windows etc) there is always the java.util.prefs API (load your defaults as a classpath resource and save user changes via java.util.prefs, registry, etc)... |