DEV Community

Discussion on: Where to start refactoring.

Collapse
 
sebnozzi profile image
Sebastian Nozzi

What I would like to share is that many times I ended up with a recursive mess of refactoring steps that I did not understand anymore. I was trying to do too much, too fast, too deep at once. And I could not back-track.

That having been the case, I would like to recommend the following:

  • Go slow. One step at a time - without rushing things. Otherwise your results won't be clean / good.
  • Go shallow. Or as shallow as possible. That is: avoid "Inception"-like deep refactorings (a refactoring within a refactoring within a refactoring with... you get the idea)
  • Go focused. Refactor one aspect at a time (don't fight many battles at once).
  • Go safe. Be able to "undo" if you mess up

Especially for the last point, but also aiding the others, I would recommend you use git & branches. Open a branch for your refactoring activities, commit as soon as you are happy with your refactoring step. If you land in a "blind alley" you will be able to go back.

Hope that helps, and have fun! Refactoring can be a very rewarding activity.

Collapse
 
drbragg profile image
Drew Bragg

All great points! I completely agree