When should a method be static?

Make methods static when they are not part of the instance. Don’t sweat the micro-optimisations.

You might find you have lots of private methods that could be static but you always call from instance methods (or each other). In that case it doesn’t really matter that much. However, if you want to actually be able to test your code, and perhaps use it from elsewhere, you might want to consider making those static methods in a different, non-instantiable class.

Leave a Comment

tech