Abstract

Writing code that does what you want it to is easy. Writing code that is easy to understand is harder. Fortunately, you are not doomed to code that no one can understand or maintain if you know how to refactor it.

Description

Refactoring is a useful but often poorly understood skill. Effective refactoring leads to code that is easier to understand, maintain, and test. In this talk, you will learn how to identify code that needs to be refactored, types of refactoring you can do, and how to verify you’ve improved your code using Code Metrics tools in Visual Studio.

Signs you need to refactor:

  • Overly long methods
  • Unclear variable and method names
  • Too many input parameters
  • Unrelated code in the same method
  • Duplicated code
  • Lots of loops

Types of refactoring:

  • Rename refactoring
  • Method extraction
  • Consolidating code

Verifying improvement with Code Metrics:

  • Maintainability (should be high)
  • Complexity (should be low)