Refactoring

How to Refactor

Refactoring is an essential step to becoming a world-class programmer, and it's important to look at your code fresh before refactoring.

Refactoring is not about solving the problem differently. It's about solving the problem well.

Good solutions don't just work. They are clear. For example:

  • Use intention-revealing names for variables and functions
  • Avoid global variables
  • Place your declarations at the top of the function or script
  • Initialise variables when you declare them
  • DRY (Don't Repeat Yourself) - create functions for reusable code
  • Readable, concise code

To understand more about best coding practices: