I was wondering why resharper suggests a method to be static in non static class? Is it for saving the creation of the instance? Is it a matter of performance? also, why does it suggest to 'const' some params? Is it a matter of performance ? I would love to get some explanation
The other answers are correct, it's just a good practice.
But I want to show how it can benefit you. Often times, when some big method can be made static, it is a hint that there's another responsibility there, which may be best handled by extracting another object for just that task.
It also can have a chain-reaction type effect - say A calls B, both non-static. Now Resharper tells us B can be made static; we let it do its thing. Now maybe A can be made static too. Maybe A is also another responsibility entirely.
This effect has come in handy for me when refactoring older code. It let me see responsibilities and points where I could cut code out without having to sweat over every inch of text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With