I've been reading that using static variables in a class that's never instantiated is a bad idea, because the variables may turn null when the class is not longer in memory. Makes sense.
This is what I've been doing for an example
public class MasterParameters {
public static boolean DEBUG_MODE = true;
protected MasterParameters(){
// Exists only to defeat instantiation.
}
}
I've also heard using a Singleton is equally bad and people suggest using "dependency injection" -- This seems complicated and overkill for what I need, however. Am I just not looking at the right examples?
I want an easy way to define a variable in one spot that can be accessed from anywhere in my code without having to pass a parameters object around. What do you suggest? Thanks :)