Code Refactoring in C#

Code refactoring allows you to change the code structure without changing or affecting what the code itself actually does. Code refactoring is the practice of taking previously written code and rewriting it to make it more efficient.


Using code refactorings:

On a symbol in the text editor.

On a code selection in the text editor.

On a file or a selection of files in the Solution Explorer tool window.

On a type member or a selection of type members in File Structure or another ReSharper tool window.


Change Signature

This refactoring allows you to modify a method signature in the following ways:

Add, remove, rename, or reorder parameter(s)

Change return type

Change parameter type(s)

Rename method


Refactoring can be explained as the process of improving your code after it has been written by changing:

The internal structure of the code.

External behavior of the code.


Methods

There are 5 methods of applying effective refactoring over your code, these methods are already available in Visual studio:

Extract Method

Extract interface

Rename

Promote variable to the parameter

Encapsulate Field

Generate method stub

No comments:

Post a Comment