forum

Home / DeveloperSection / Forums / Why are static variables considered evil?

Why are static variables considered evil?

Anonymous User201720-Jul-2015
I am a Java programmer who is new to the corporate world. Recently I've developed an application using Groovy and Java. All through the code I've used quite a good number of statics. I was asked by the senior technical lot to cut down on the number of statics used. I've googled about the same, and I find that many programmers are fairly against using static variables.

I find static variables more convenient to use. And I presume that they are efficient too (please correct me if I am wrong), because if I had to make 10,000 calls to a function within a class, I would be glad to make the method static and use a straightforward class.methodCall() on it instead of cluttering the memory with 10,000 instances of the class, right?

Moreover statics reduce the inter-dependencies on the other parts of the code. They can act as perfect state holders. Adding to this I find that statics are widely implemented in some languages like Smalltalk and Scala. So why is this oppression for statics prevalent among programmers (especially in the world of Java)?

PS: please do correct me if my assumptions about statics are wrong.

Updated on 20-Jul-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By