Luxor Forums - White Hat & Community Forums
Are static methods evil?
#1
Are static methods evil?

When I was learning OOP I was taught by my mentor (previous job) to avoid static methods at all costs and that if I am using static methods then I am not properly architecting my application. I just trusted what he said because he had 35 years of experience programming and was the companies CTO. A really smart guy.

I just started a new job who has a pretty bad code base. They just started using OOP in their application (barely OOP). They don’t namespace, the few OOP classes they use are pretty bad. Some files have an interface, abstract class, then a few other classes all in file. They use includes halfway through a script. They use proprietary file manager.

Most changes that need to be made I am clear on because through practice I have seen the benefits of them. However, this code base has a LOT of static methods. When I asked them why they told me its because of performance.

A static method call doesn’t need to have its class instantiated and therefore runs faster.

How true is that? (Hard for me to take advice from someone with such a poor code base) Is it really a big performance increase?

What are some pros and cons of static methods?

PROS - perfomance.

CONS

submitted by /u/UnFukWit4ble
[link] [comments]
Possibly Related Threads...
Thread
Author
  /  
Last Post