Why refactor? you know better why, because we have written crappy codes and its making our life hell, and killing lots of precious development hours. we could write thousands of line just to describe why we need refactoring, but lets not go in that debate.
We are here to learn refactoring features provided by visual studio to clean up our codes. The refactoring techniques are given bellow.
- Extract Method
- Encapsulate Field
- Extract interface
- Promote Local Variable to Parameter
- Remove parameters
- Reorder parameters
Bellow a screen shot from visual studio is given
All of the refactoring have shortcut associated with it and all of them are two key shortcut. Starts with CTRL+R, and followed by CTRL+”ANY Main Key”. for instance R is for Rename. Bellow example of rename refactor is given.
Step 1: Select the class, property, variable, field, or method. hit CTRL+R followed by CTRL+R, a window will popup and then put required name then click ok. if preview is been selected, it would popup another window.
Step 2: A preview will be shown what the ide will going to do with the name provided. Click apply to proceed.
This is just a tip of the iceberg. There are huge possibilities with this new features, how we use it and whether we choose to use it or not totally depends on us. And I highly recommend to use this refactor feature more and more.