Hacker News new | ask | show | jobs
by hinkley 817 days ago
It was five to six lines of code repeated in half a dozen spots in a dozen files, with different variable names, and different arguments. And I wasn’t deleting them, I was replacing them with the same function call.
1 comments

That’s got “macro” written all over it.
That's a sed /d of course. Or a "Replace all in folder" in any decent code editor.

Or a sufficiently efficient "extract to method" on a decent IDE, that notices the different occurrences even with renamed variables.

Unless those lines of code were subtly edited all over the place and needed careful and subtly different replace for each occurrence, or at last review because that's what's truly evil with duplicated code. It's forks that diverged to maintain N times in your codebase.