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.
Asked
Active
Viewed 240 times
0
-
unclear, please edit question. What programming language ? To do what ? in which context ? – kebs Dec 05 '14 at 23:06
-
You can take a look at this: http://stackoverflow.com/questions/8864720/properties-or-enums-or-static-final – Marcelo Tataje Dec 05 '14 at 23:28
1 Answers
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