Lately, I've come across a lot of Java code that relies on "properties files" for configuration. But instead of plain old string literals, the code uses constants (static final Strings) to retrieve the property values .
I find this extra level of indirection annoying because I need to perform TWO lookups in EITHER direction. If I start with the property observed in the config file, I have to first search for the property name to find the Java constant, and then search again to find the references to the constant in the code. If I start in the code, I have to find the actual value of the constant before I can then determine the value of the property in the config file!
What's the point?
I understand the value of using constants to reference keys in a resource bundle, usually in support of i18n. I'm referring to simple, non-user-facing config values. The only reason I can think of is to make it easy to change the property name later, but this benefit is far less than the annoyance IMHO, especially given the ease of a global search and replace.
For one thing, you cannot mistype the keys when using constants without getting a compiler error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With