November 14, 2008

When to use static methods

I started using Resharper again after some time. And one thing that bugs me is that it always warns me that functions can be made static. I've kinda stopped using static methods. Static methods arent injectable, static methods make code using them less modular and less testable and static methods are the devils own handywork if you want to believe some people. On the other hand they make your code simpler by not requiring an object instance to be called. This got me thinking. Do I want to use statics or just ban them completely? And if not when is it ok to use them?