Refactoring JavaScript — 5 Common problems to look out for and how to fix them

Click for: original source

Refactoring is like the NeverEnding Story: you might think you’re done, but as long as the plot (the project) is ongoing, there is always room for more changes. By Fernando Doglio.

The problem though, comes when we focus on the wrong aspect of our code looking for things to refactor. After all, a good refactor normally means running the risk of breaking a working feature, so you better make damn sure that whatever you’re trying to change, is worth it.

The article covers:

  • Magic values
  • Abusing primitive values
  • Duplicated code
  • Callback hell or unending promise chains
  • Spread responsibility

Keeping your code clean through refactor is a never-ending task, and that’s why author covers it as a completely separate topic in his latest book, Code Well With Others. Good read!

[Read More]

Tags code-refactoring app-development learning javascript