Copy link to clipboard
Copied
Ls,
Im a beginner when it comes to OOP.
Not wanting to pass everything thru the class calls, i want to be able to have some application globals.
Can define them package level?
Should I create a class globals.as with static vars?
Whats the proper way of doing this?
Any help is greatly appreaciated.
Mac
firstly I would say that there are few instances where you would need global variables, I haven't used any in a long time and at the moment I can't think of any situation where i would. Although saying that it may be the easier solution if you are new to OOP.
if I were to do this I would use a class with statics vars as you said
Copy link to clipboard
Copied
firstly I would say that there are few instances where you would need global variables, I haven't used any in a long time and at the moment I can't think of any situation where i would. Although saying that it may be the easier solution if you are new to OOP.
if I were to do this I would use a class with statics vars as you said
Copy link to clipboard
Copied
yes, you can use a class that has static variables. if you want your class to validate the variables, you can use private static variables and public getters and settings. otherwise, you can use public static variables.
Copy link to clipboard
Copied
Thank you both!
I noticed that now im understanding OOP a bit better I finf great pleasure in the way things are accessible.
In one case though I have somve very large vectors.
I thought it would benefit performance if I could just access these directly from any class.
Mac
Copy link to clipboard
Copied
I dont use glabal vars anymore, more like a global class in the form of a Model that I inject into views (via presenters) using Swiz