need opinion on public static final etc ...
Everything works as intended. I am looking for conceptual advise. Am i doing it the right way from design stand point?
Suppose a contains the following declarations:
So why public, why final, why static?
public final static char DELIMITER = '\u0002';
public final static char ERROR_SIGN = '\u0003';
Idea was that since A is the first class that encounters these variables, it is a right place to declare them at. It is public, because going in, i thought other classes will take advantage of this declaration. It is static because only a single instance of it exists in my universe and it is final, because it will never change
That being said, after declaration, public class A later continues to use them locally.
As mentioned before, this first time these variables are introduced ... Until set here at A, no other class needs to worry about them.
Moving on .. here comes Say it uses A.DELIMITER 20 times and A.ERROR_SIGN 10 times
Moving on .. here comes This guy uses these delimiters to split a string 300,000,000 (not really, but plenty) times so it does this
After this class C continues to refer to local errorSign and delimiter
// do translation to String once instead of tons of times below
private String errorSign = (Character.toString(A.ERROR_SIGN));
private String delimiter = (Character.toString(A.DELIMITER));
And so, i wonder ... is this a right approach? Should class A be the class where public static final vars are declared? Should i make a new separate class for this? Is approach i followed in class C appropriate?
Generally speaking, how do you deal with something like this?
Please advise and thanks for reading