Rant: Copy and Paste Programming
Let me forwarn you that you may be offended by this post… it may come off as a bit hostile and derogatory, but it’s just something I need to get off my chest. When someone thinks it’s entirely acceptable to write a 300 line method and call it “the quickest and simplest thing to do that works” and then copy and paste those 300 lines 10 times and modify maybe one or two variables to cover other scenarios, you don’t deserve to even have a job programming.
I’m sorry, but I don’t care what your time constraints are. I don’t care that you just learned the language. And I don’t care you sat down and thought “OMGZ! I need to get this done yesterday!” The fact that you did not just try to use that thing you call a brain and THINK about what you were doing and just reduced yourself to a CTRL+C and CTRL+V keyboard monkey reduces any possiblity that I could respect you as a programmer. Honestly, did you get through school by copying homework assignments? Did you get the genius next door to do your work for you while you were out partying, and luckily had awesome memorization skills to pass exams?
A skilled craftsman is one who devotes their time and energy to honing their skill. They may start out knowing very little, but through dedication and at least using their brain they improve, and even if their code isn’t perfect, at least they gave it effort. By just mindlessly copy and pasting you didn’t even make an effort… you’re just lazy.
When you need to do something similar to something else, maybe it’s okay to copy and paste the first time, change a few things, then look at what you can do to consilidate both tasks and make the same code useable in both situations. But doing the whole copy and paste and saying “I’ll refactor it later” is idiotic… you know that “later” is never going to come, and with that attitude you’re just going to keep doing it over and over to the point that “refactoring it later” will take you 30 days.
Let’s just be honest to ourselves… there’s really no reason you should copy and paste your code. Period.
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!








April 28th, 2007 at 2:02 pm
I’ve been in this industry for over 12 years and I see this a *lot*.
I share your sentiments. There are a substantial amount of people who don’t view their work as a craft and just want to move on to their next piece asap.
I think one of the factors is that these people never seem to clean there crap up.
It’s inevitably left to people who do care, to fix ‘just one little thing’ and it turns into one big refactoring project. Then the comments of how long it took to do such a small enhancement. grrrhhh..
April 28th, 2007 at 7:21 pm
If you are java developer you can use some good tools: JetBrains IDEA contains smart duplicate detector (which will not be tricked by changed identifiers or expressions) and TeamCity 2 can provide you regular browsable reports for new dupes.
April 29th, 2007 at 4:33 am
This sounds so familiar. A while ago I wrote a blog about this subject after reading 15.000 lines of code. Those 15.000 lines should have been about 250 lines, but someone loved copying around:
http://technology.amis.nl/blog/?p=1866
April 30th, 2007 at 6:39 pm
Great post. I couldn’t agree more. I don’t know how many times copy-paste (all in the name of meeting the deadline) has come back to bite us on the ass on my current project.
I blogged something along a similar vein just yesterday: http://on-agile.blogspot.com/2007/04/why-you-wont-fix-it-later.html
Cheers,
Ryan
December 15th, 2007 at 7:44 am
very interesting, but I don’t agree with you
Idetrorce