Refactoring is restructuring your code to be more efficient and/or organized. The functionality of the code doesn’t change.
Refactoring has challenged my usage of git. Usually my writing is linear, with an occasional
git reset --hard HEAD
But the “final” phase of my last project got me so messed up, I needed to move back a few commits and ended up making a branch and then accidentally submitting a pull request to Hack Reactor like an idiot. I was then left with a pile of burning code at 1am with no stamina to figure out what I had done wrong. (I still don’t understand exactly how I got it so bad, but there’s some reason why that primary html file is always named “index,” don’t change it.)
Tips on writing code that you can refactor:
- Ignoring spacing style now will cause you pain later.
- You can have the same name for a class, ID, and variable. But you DON’T want that.
- When you notice a different sector of your code goes down while refactoring, make sure you remember exactly at which step that happened.
- Don’t save refactoring for 10PM the day before its due