Losing My Mind Refactoring Legacy Code
Variable names are a, b, aa, aaa, aaaa... There's exactly one comment: '// Don't modify this part'
It feels like it'd be faster to just rewrite it from scratch, but my team lead says not to touch it lol ha...
9 answers
LOLOLOL I saw aaaa and cracked up
Ah, the 'Don't modify this' comment is the scariest. Nine times out of ten, if you touch it, production goes down.
It's not that the team lead is wrong—legacy refactoring without test coverage is just gambling. The moment it feels faster to rewrite it from scratch is the most dangerous moment. At the very least, start by documenting what that aaaa does.
Any sources?
Well, that's a bit much. Just because they said not to touch it doesn't necessarily mean don't refactor—isn't it just saying to keep things stable? Hear the team lead out too before you decide.
Same here... In my code, the variable names are data, data2, data_final, data_final_real. Funny but sad.
I disagree. The idea that rewriting from scratch is faster is an illusion most of the time. By the time you think you’ve fully grasped the requirements, you’ve already missed half of them. If you want to rewrite just because refactoring is boring, that’s just escapism.
Is the person who wrote that comment still at the company? If so, buy them a meal and ask why it shouldn't be touched. That's the fastest way. Agreed.
One practical tip: don't try to change a, b, and aa all at once. Use IDE rename to split it into one variable per commit. Reviewers won't be as scared, and your team lead will say 'don't touch that' less. Don't delete comments—at least leave a reason in the form '// why: '.