I have an application with 100+ static variables and methods in its Application class will it affect the performance of the app? if so how to handle it?
-
4maybe your design is a bit wrong thoughScary Wombat– Scary Wombat2016-11-22 06:03:29 +00:00Commented Nov 22, 2016 at 6:03
-
any alternate way to handle it?Vignesh Palanichamy– Vignesh Palanichamy2016-11-22 06:04:21 +00:00Commented Nov 22, 2016 at 6:04
-
1Create a helper class and put them in it!A. Badakhshan– A. Badakhshan2016-11-22 06:06:21 +00:00Commented Nov 22, 2016 at 6:06
-
1try this stackoverflow.com/questions/6196027/…Pavneet_Singh– Pavneet_Singh2016-11-22 06:07:13 +00:00Commented Nov 22, 2016 at 6:07
-
1@Henry, I don't think that he is trying to save his data in static variables. I think his wants to access them everywhere in his app.A. Badakhshan– A. Badakhshan2016-11-22 06:11:35 +00:00Commented Nov 22, 2016 at 6:11
1 Answer
As I see, your only question is if using static methods and variables inside your application class is wrong or not. As far as I know, it will not affect your application performance or anything else, but putting them inside application class is a wrong design. It's like you put all your code inside one single method and it will not be good.
So, I suggest you to put your static methods inside a Helper class and since they don't need to be instantiated, they need to be static, not a singleton. Also for your variables, for example for your Strings, I suggest to create another class and put them into it so your application maintenance be possible.