This is why I introduced the "Copy & Paste Error Scorecard" to my (small) team. Everybody manages to give away points from time to time. More serious points could be scored for mistakes getting as far as Git, but the best points are the ones it takes about 4-5 minutes of going "huh?" to spot. Its nice to remember that copy-and-paste tooling is a privilege, not a programmers' right.
And while I'm here,
My favorite technique for reducing these mistakes - is using "highlight occurrences" in the IDE, with a nice bright color ; click the cursor on a variable or method call, all matching uses jump out at you.
This gives a great visual pattern when working in copy-pasted code blocks.
And while I'm here, My favorite technique for reducing these mistakes - is using "highlight occurrences" in the IDE, with a nice bright color ; click the cursor on a variable or method call, all matching uses jump out at you. This gives a great visual pattern when working in copy-pasted code blocks.