Are you guilty of commenting out legacy code?
Published August 6th, 2019 • ☕ 1 min read
When you refactor code, you do what? At some point, I guess you comment out the now-to-become-legacy. As a backup, just in case. I mean, who is going to browse through all the git commits to see what it looked like earlier?
Let me tell you: Your old code has to die. Be better than this and press the backspace button on it. When you wrote that code, you were you from weeks, maybe even months or years ago. You are someone else now. You are you from the present, and your thinking and coding skills have advanced way too much to be held back by your past.
It's not a backup, it's not a security. It's just one more irrelevant thing that sits in your subconsciousness as a TODO and will restrict your future thinking and creativity by providing an outdated (hence the refactoring) solution that you actually want to get rid of.
And in the absolute worst-case scenario, you are using Git and can revert anyway. You are using git, aren't you?.
Do you remember that one time you wrote that paper for college and your hard drive died? In hindsight, wouldn't you say it has made the essay better to had it written a second time with all your previous work lost?
Have you heard the story of Steve Jobs throwing an iPod into an aquarium without even examining it before? Whether it's true or not, it forced the Apple engineers to start over from scratch, with no backup, but with the knowledge which they gathered from building the prototype.
So do it, delete it. You will also need to get rid of your doubts. It's the nagging voice in your head that's screaming, "But what if... ?". Lose your mercy. Delete it, then reinvent.