Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Constants or properties file - best practice question

661599Mar 6 2011 — edited Mar 7 2011
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2011
Added on Mar 6 2011
6 comments
2,676 views