Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the naming conventions for Java .properties files?

I plan to create a global properties file for use across the application, and several properties files available only for specific classes and methods. Is there any particular industry standard for naming the property files?

like image 469
Radan Avatar asked Feb 18 '13 16:02

Radan


People also ask

What are naming conventions for files?

A File Naming Convention (FNC) is a framework for naming your files in a way that describes what they contain and how they relate to other files. Developing an FNC is done through identifying the key elements of the project, the important differences and commonalities between your files.

What is in .properties file?

. properties is a file extension for files mainly used in Java-related technologies to store the configurable parameters of an application. They can also be used for storing strings for Internationalization and localization; these are known as Property Resource Bundles.

What is config properties file in Java?

What is the use of config.properties file in selenium. Properties are used to externalize the data which is configurable and if you put that data in your code (test script) you have to build the code each time you want to change the value of the property.


1 Answers

To my knowledge, there is no set rule.

The naming convention I go by is if it is a properties for a single class, I use {ClassName}.properties, otherwise I use {WhatIsItUsedFor}.properties, and occasionally if it's for a single application, {ApplicationName}.properties. I have a preference for CamelCase; others prefer lowercase.

For the names of properties themselves, if granularity is possible, I use something like

{ClassName}.{MethodNameIfNeeded}.{IntendedVariable}={value}

Do realize the more property files you have, the more potential maintenance issues you create. Some are better off consolidating to a single properties file, using the property/value naming convention (above) to single-out any classes requiring their own configuration.

like image 80
JoshDM Avatar answered Oct 22 '22 21:10

JoshDM