So, I know how to refer to variables from different classes, but I'm wondering if I should create Vars.class to host all of my global vars.
No. First of all, you should try to avoid global variables. Variables should represent the state of a particular object - so group variables are in accordance with reasonable boundaries for useful objects, and then make sure that each object is aware of any other objects in which it should depend.
It makes little sense to use an object-oriented language if you are going to throw away object orientation.
Taking the time to develop the appropriate types in your application will no doubt be slower in a very short time than just having global variables ... but it will make your code much easier to maintain and test.
As for performance: you are too worried about this too soon. Access time for variables will almost never be a significant effect. Create your code in the easiest way. Define performance criteria and eligibility criteria. See if your code meets these criteria. If it is not, find out why it is not, and make the cleanest change that you can improve to work (all the time).
In addition, the variables themselves should almost always be private: storage is a solution for implementation; consider how and how to expose state through methods.
source share