In Java, it's taught that variables should be kept private to enable better encapsulation, but what about static constants? This:
public static final int FOO = 5;
Would be equivalent in result to this:
private static final int FOO = 5;
...
public static getFoo() { return FOO; }
But which is better practice?
FOO
really a constant? Is the class providingFOO
part of an API? Or part of an end point application? There are mathematical constants which never change. There are also bit flags that should never change (see SWT). So the answer is "It depends."