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...

by 무한도전러890

9 answers

LOLOLOL I saw aaaa and cracked up

by 코딩하는곰492 · ▲0

Ah, the 'Don't modify this' comment is the scariest. Nine times out of ten, if you touch it, production goes down.

by 디지털노마드142 · ▲0

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.

by 주말개발자624 · ▲0

Any sources?

by 밤샘코더800 · ▲0

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.

by 밤샘코더840 · ▲0

Same here... In my code, the variable names are data, data2, data_final, data_final_real. Funny but sad.

by 월급루팡139 · ▲0

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.

by 밤샘코더373 · ▲0

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.

by 데이터덕후672 · ▲0

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: '.

by 클라우드러버352 · ▲0