2

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?

12
  • 4
    maybe your design is a bit wrong though Commented Nov 22, 2016 at 6:03
  • any alternate way to handle it? Commented Nov 22, 2016 at 6:04
  • 1
    Create a helper class and put them in it! Commented Nov 22, 2016 at 6:06
  • 1
    try this stackoverflow.com/questions/6196027/… Commented 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. Commented Nov 22, 2016 at 6:11

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

If the number of static variables increases, more memory is consumed.
See for example this question stackoverflow.com/questions/4797187/… why this is not a good idea.
Guys his question is not what you are answering. I agree with both of you, but his question is another thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.