I am pretty new to Java and I have been spending lots of time creating small applications for practice and on one of them, I wanted to have the version appear in many different parts of the gui (login window, title bar, help window, etc). I create a class called StandardText with some static variables marked private. I have pasted some sample code below. I then created some getter methods to retrieve the static variables and then I was sitting here thinking that why do I need the getter methods, the variables are already static, if I mark them public, I will be able to access them direct. My question is two parts:
1) Which way is the better method of practice, private static variables with getter methods that are also static or public static variables with no getter method?
2) Is there are better practice of doing what I am doing?
If you let the code access the variable directly then there is no way (without rewriting your code) to add behaviour to what you return. For instance if you later decide to make you program multi-lingual then you have to rewrite your code. If you accessed it with a getter then you only need to change your getter method.
In practise it is almost always better to use getter/setter methods because of these reasons.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.