It is nigh impossible to resist the urge to copy a file or a block of code to repurpose it. This is a good thing to reuse working code. Just Ctrl-C, Ctrl-V, rename what needs renaming and you’re done.

Right?

Wrong!

All too often this ‘easy’ task goes off the rails and your code gets broken in the process. It is too easy to miss something in your rename process, to miss a required change.

All too often the least that goes wrong is the error messages and comments talk about the old version.

So… the rule to make Cut & Paste Programming work is: always rewrite the whole the whole thing from top to bottom. As if you’ve never seen it before, line by line, clean it up.

Or if you are really good just refactor the module to a more generic form and call it with appropriate parameters, that is the right solution.