What are the naming conventions for property names defined in properties files in Java? Can I use uppercase or only lowercase?
For example: bankAccountNumber or bank.acc
In JSF you can see in ValidationMessages.properties something
javax.validation.constraints.Pattern.message
or in JsfMessages.properties
javax.faces.component.UISelectOne.INVALID
So you can use wherever you like, i like just lowercase, package formatted
As per my understanding, there is no any standard rule written for .properties
file in java.
but if you see the .properties
files inside the lib
folder of Java\jre
most of them have lower cased .properties
file names. And the properties
themselves are also lower cased.
such as:
psfontj2d.properties
key values
courier_new=courier
courier_new_bold=courier_bold
Actually Resource Bundle accepts only fully qualified base name of the bundle, with no file extension. In this case it will try to load the bundle of files like this
messages/EN/properties.properties
I am sure you intend something different than the conventional internationalization, but convention would have been "messages_en.properties" (en when language, EN when country)
Naming convention is recommended as lowercase in property file.
bank.account.number
this is more appreciable.
I guess there is no such common conventions for property files. However, using lowercase letters in an eligible/easy-to-understand format (e.g. bank.account.number) sounds good, and using the property files with their original extensions (.properties) is also recommended.
There's no particular standard for naming properties, but convention appears to be of the form
a.b.c.d = x
in lowercase. I would expect some sort of informal hierarchy e.g.
bank.
bank.account.
bank.account.name.
bank.account.pin.
etc.
If it's a property which directly affects a particular class I may name it after that class (or at least use the package name). However that is also an example of implementation leak, and I'd think seriously before doing that.