Code Refactoring

There are some rules that I try to follow when refactoring code:

  • DRY (Don't Repeat Yourself): identify and eliminate code duplication by abstracting common functionality into reusable functions, classes, or modules.
  • Rule of three: same code can be repeated twice, but the third time it should be refactored into a new function or module. This applies to logic that is likely to be modified in the future.