C# – First steps with C# and .NET – part 025 .

Refactoring is the process of modifying code in order to make it easier to maintain, understand, and extend, but without changing its behavior., see Wikipedia webpage.
If you use an integrated development environment known as I.D.E. then some refactoring commands are present under the refactoring menu.
If not, then you need to do it manually.
Steps for refactoring process:

  • Extract Method – t is used to create a new method from an existing
    code fragment;
  • Rename – rename fields, local variables, methods,
    namespaces, properties and types;
  • Encapsulate Field – create a property from an existing
    field;
  • Extract Interface – create new interfaces from an existing class,
    structure or interface;
  • Promote Local Variable to Parameter – convert a local variable of a function to its parameter;
  • Remove Parameters – remove a parameter from a methods, indexes, or
    delegates;
  • Reorder Parameters – change the sequence of the parameter list a
    methods, indexes or delegates;
  • Generate method stub – this generate the I.D.E. to generate the methods stubs;
  • Convert to interpolated string – this simplify interpolation for strings, like interpolation with the syntax $”{parameter}”;

If you test and look for actions in development, you can find many proposals for the refactoring process.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.