Just a quick sanity check on the correct "OO" way to handle properties...
My properties model consists of class named PropertiesManager that contains a private static Properties object, and all of the methods for getting/setting properties are public static. This lets me easily get/put a property from anywhere in my application. Since there are no non-static member variables, I did not see a reason to actually instantiate a new PropertiesManager object whenever I wanted to get a property.
How did you (collective) handle obtaining properties values throughout your code and does my way seem acceptable?
posted 8 years ago
I've implemented this pretty much exactly the way you have. The only difference I can think of is that my equivalent of 'PropertyManager' is more generic - I've called it 'Config', and the public API comments make no reference to the Properties class. To my mind, the backing Properties instance is an implementation detail. My class has some other config-related methods that don't use the Properties instance.
A nice thing about this setup is that your getter/setters can parse the fields and convert them into different types. For instance, if you have a numeric property, your getter/setter for that field can convert to/from int. This approach can be extended as far as Lists.
get schwifty. tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads