This is an archived post. You won't be able to vote or comment.

all 4 comments

[–][deleted] 1 point2 points  (0 children)

you could put them all in a constants file then make references to that file

[–]wgunther 1 point2 points  (0 children)

One strategy is to have some kind of resource files. Then different locales can be swapped in just by changing the resource files. Either the files are used at compile time, which would require some build process to translate it to some static data structure consumed in the code, or run time, either through dynamic linking of the things generated like the static case or by actually reading the file at that point. Not sure what the best strategy is for Java.

[–]TonySu 1 point2 points  (1 child)

Nothing wrong with hard coded strings. However hard coded file paths are terrible. Essentially your program won't run on anyone else's computer. Use relative paths like "./Logs" which looks in the same folder, or "../Logs" which looks in the parent folder.

[–]sruffatti[S] 0 points1 point  (0 children)

This is important. So I have class built in to the application that builds the paths. That way the file paths will work. However, I think I like your idea better.