Constants or properties file - best practice question
661599Mar 6 2011 — edited Mar 7 2011Hi,
My application has a number of values that will be used in different classes throughout my project. For example, I perform a check against the max allowed length of an ID in numerous places in my code.
Therefore, it makes sense to set this value in a central location, and refer to it as a variable where it is required in my code.
I see in other projects that using a public static final member in a Constants class is used to set these types of values. Is this recommended or best practice?
The only alternative I can think of would be to use a properties file, and inject the value using Spring etc.
What is considered best practice or the neatest way for doing this?
Thanks