The point is to make changes aiming to improve the current or future maintainability and reliability of a software system. Here, the internal structure is improved.

Types

  • Floss refactoring
    • Frequent refactoring interleaved with other kinds of program changes
  • Root canal refactoring
    • Infrequent, protracted periods of refactoring, during which programmers perform few if any other kinds of program changes
  • Flossing helps maintain health and root canals correct unhealthy code.

Note

If you see the same code structure in more than one place, find a way to unify them.

Long Methods

The longer a method is, the more difficult it is to understand. Larger modules are associated with higher error-proneness and change-proneness. Extracting code fragments having a distinct functionality into new methods can improve the understandability.

If a module is very cohesive though, it may be okay to be long. Decomposing a highly cohesive module would introduce excessive code duplication between the original module and the newly extracted modules.