0

I am looking for suggestions on what the best practice is for declaring URLs. Property files or enum? Edit : I use Java as my programming language.

user3325862
  • 121
  • 2
  • 7

1 Answers1

1

Use hardwired constants in your Java code when you don't want users / deployers / testers / tests changing them.

Use a properties file when you do want this to be a possibility.

The point is that changing a hard-wired constant in your application's source code entails editing the source code, rebuilding and redeploying. By contrast, changing a properties file may be as simple as firing up NotePad.

Constants - when you don't mind re-compiling the application each time you change value. Sort of an irony here. Why would you change something if it has been called a constant :)

Properties file - when you want the luxury of just changing the value and maybe restarting the application to pick up the change.

aurelius
  • 3,946
  • 7
  • 40
  • 73