How often do you clean your car? How often do you clean your code? If your answer is never you should consider reserving some time to refactor problem areas of your code. Clean code is easier to test and debug, so the time spent refactoring will likely be worth it in the end.
Visual Studio has some great features for refactoring code. Personally, I use the rename feature quite often. Rename is more then “find and replace”, it’s an intelligent function and will even stop you if the name you picked will cause problems.
There is also ability to extract a method from lines of code. This feature is great for when a method grows too large and you would like to split it into smaller pieces.
The refactoring tools are not only for existing code – they can also help when you are creating a new class. There are tools for generating properties, building constructors, overriding the Equals method and more. Automatically generating properties is an amazing time saver when creating a class with many properties (like a ViewModel). This docs page from Microsoft details all of the available refactoring functions in Visual Studio.
Now go clean some code!
Thanks Nick for the suggestion!