Do I need to use static methods instead of non-static ones when having tons of instances of the class?

51 Views Asked by At

I Have a class called car, this class have multiple methods (about 30) to handle things such: starting car, stopping, opening doors ...

  • The problem is that my program have thousands of instances of the class car. I noticed I can refactor the class into having member variables that define each instance of a car class, and for the methods they can be made into static methods that takes the instance of the car class as parameter and do the necessary things on it.
  • My question is: is static methods going to be better on memory usage or the refactoring doesn't worth it? in other words is using non-static methods going to take up memory for each instance of the car class?
0

There are 0 best solutions below