There are various refactoring options in Visual Studio to use at the time of coding. When we extract and create a new method. Then Visual Studio decide whether the new method will be static or instence depending on the usage inside the new method. If that method use some intence member of the class then it creates as instence method, if it does not use any instence member of the class then it creates the method as static. I can understand that if there is no instence member usage then it is better to declare that method as static to prevent initialization for every object. Static method initilize only once at the time of class load.But the question is if there are many static methods inside various classes of a application, then performance will hurt? Because many object of that class will share same static method of that class? Should we do thread safety management to that static method? Or in this kind of setuation it is better to simplily create instence method if there are no usage of instence member of the class?
Is it good to create static method at Visual Studio refactoring?
refactoring;visual studio;static methods
It's not so much a performance issue but a thread safety issue. If you have static methods that mutate static data then yes, these will need to lock access to that data (though granted this could cause performance issues), this of course is also true of non static methods. However it is much more common for static methods to be pure functions in the first place, in this case no locks may be required. 