The Senior Developer's Mantra: The Best Refactor is Deletion
Description
A screenshot of a tweet from Greg Brockman, co-founder of OpenAI, with the Twitter handle @gdb. The tweet, displayed in white text on a black background, contains the concise and profound statement: 'the best refactor is to delete the code'. Below the text, engagement metrics show significant interaction, indicating the sentiment resonates widely within the tech community. This piece of advice is considered a core tenet of senior-level software engineering. It posits that the most effective way to improve code quality, reduce complexity, and eliminate technical debt is not to restructure or rewrite code, but to remove it entirely. This implies that the feature the code supports may be unnecessary, over-engineered, or solved by a simpler, existing solution. It's a powerful statement about prioritizing simplicity and challenging the assumption that more code equals more value
Comments
11Comment deleted
The junior engineer proudly announces they've added 500 lines of code. The senior engineer proudly announces they've deleted 1000. The principal engineer has prevented the meeting that would have generated the feature request in the first place
Architects know the fastest way to hit five-nines is to ship /dev/null to prod
After 20 years in tech, you realize the most valuable PR is the one with the most red lines - because the only code that never breaks is the code that doesn't exist. Somewhere, a principal engineer is nodding while deleting their entire microservices architecture
Ah yes, the 10x engineer's secret weapon: achieving negative lines of code. While junior devs measure productivity by commits added, seasoned architects know the real art is in what you *don't* build. Every line deleted is one less line to debug at 3 AM, one less dependency to update when the next CVE drops, and one less thing to explain during the architecture review. It's the Marie Kondo approach to software engineering - if that code doesn't spark joy (or revenue), thank it for its service and `git rm` it into oblivion. The best part? Your code coverage percentage goes up automatically
Deleting code is the only refactor guaranteed to reduce cyclomatic complexity without a single regression
My highest-ROI refactor was a -3,842 LOC PR - on-call got quieter, CVEs vanished, and the architecture diagram finally fit on one slide
Best PR I ever shipped was literally 'git rm -r'; reviewers loved the reduced cognitive load and attack surface, and the only regression was the LOC dashboard
Finally good clean code advices Comment deleted
clean and clear Comment deleted
When I delete my code, Sonar says there are fewer bugs and code smells :) Comment deleted
Every program has at least one bug and can be shortened by at least one instruction -- from which, by induction, one can deduce that every program can be reduced to one instruction which doesn't work. Comment deleted