Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This question already has an answer here:

When ever I am stuck with a particular problem, I search for a solution in Google.

And then I try to understand the code and tweak it according to my requirement.

For example recently I had asked a question Reading xml document in firefox in stack overflow.

Soufiane Hassou gave me a link to w3schools, where I found a example on parsing xml document, I understood how the example works, but I copied the code and tweaked it according to my requirement, since I don't like typing much.

So does this make me a copy/paste programmer?

How do you say if a person is a copy/paste programmer ?

Thanks.

share|improve this question

marked as duplicate by MichaelT, gnat, GlenH7, Martijn Pieters, Bart van Ingen Schenau Feb 22 at 12:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

13  
You're one up from a c&p programmer and one below a programmer that would read other people's code before writing their own. –  dan_waterworth Dec 31 '10 at 8:25
4  
As other people said below, you don't sound like a "true" c/p programmer, but you might want to start liking typing, if you advance in your career, you'll be able to c/p less and less IMHO.. –  dr Hannibal Lecter Dec 31 '10 at 8:33
5  
A true copy/paste programmer would have multiple differently-tweaked copies of that code, each with a different set of old bugs fixed and new bugs added. However, your copy/paste/adapt could be a problem if you're not careful to ensure that those code snippets don't have copyright issues attached. An online tutorial might have copied a code snippet illegally, and you might be considered as responsible in copying that as the tutorial author was. It's probably very easy to copy snippets from employers code into notes, then forget the source later when writing a tutorial. If in doubt, rewrite. –  Steve314 Dec 31 '10 at 10:47
8  
Good Artists copy, great artists steal -Pablo picaso and programmers are artists too just my correct opinion –  Narayan Dec 31 '10 at 13:30
10  
OT, but... w3schools is often awful - take what you find there, code or info, with a grain of salt. Actually, do this for code you find anywhere - even Stack Overflow. Just because it appears to work doesn't mean there aren't bodies in the basement... –  Shog9 Dec 31 '10 at 20:46
show 14 more comments

17 Answers

up vote 29 down vote accepted

Looks like I'm going to be the lone dissenting view here.

First of all, we need to distinguish between copy-and-paste programming and cargo cult programming, as it seems that several people are conflating the two.

Copy and paste programming refers to the practice of copying and pasting the same code over and over again into different parts of a program, either verbatim or with only minor changes, instead of creating classes or subroutines or whatever higher-order code structures are offered by the language. Sometimes this is a symptom of a deficiency in the language/environment itself, but more often it is because the programmer does not understand (or value) abstraction.

Clearly, you're not a copy-and-paste programmer unless this is what you're doing. But it's obvious from your description of your activities that this isn't the question you're asking.

What you're actually referring to is called cargo cult programming. That is a set of anti-patterns, one among them being the wholesale copying of code from other parts of the program or from external sources, without really understanding how they work or if they're necessary at all.

It may be true that many programmers do this to a very limited extent. For example, sometimes we need to work around a bug in the framework or the operating system, and we'll just copy some well-known workaround because we're not really interested in learning all about somebody else's bug that we can't possibly fix ourselves. But for a professional programmer, these cases should be few and far between.

If you find yourself doing this frequently then it should be a red flag to you. And you've made this very unconvincing assertion:

[...] then I try to understand the code and tweak it according to my requirement.

Maybe this is true. Maybe. The problem is that every cargo-cult programmer will say this. The question is, do you really understand it? Truly?

Do you understand it to a sufficient extent that you could write it from scratch if you had to, given sufficient time? Would the result be reasonably free of bugs?

Or are you just making random changes to the code you copied until you hit the magic combination that does what you want?

I'm not leveling accusations; I've never met you, I know nothing about you. But this is something you need to think about.

A simple test is: Do you find yourself editing and recompiling very frequently when you are in the process of "tweaking" the code? Or do you read the code maybe once or twice, and immediately know what needs to be changed and how?

If your changes/tweaks are working on the first or maybe second try, you probably have actually understood the code you've appropriated. If you seem to be experimenting a lot with the copied code, then I'm sorry to say you are a cargo-cult programmer.

Keep that in mind for next time. Watch how you approach the problem. If you find yourself doing the coding equivalent of mashing buttons on a game pad, then you need to slow down, and try to learn a little more about the library or algorithm you are attempting to use, before going any further.

share|improve this answer
1  
Fully agree, especially with "Do you understand it to a sufficient extent that you could write it from scratch if you had to, given sufficient time? Would the result be reasonably free of bugs?" In my eyes this is the real difference. –  Oak Jan 4 '11 at 9:15
show 2 more comments

If "copy/paste programmer" is a negative, then I would say "No, you are not one". What you do it perfectly fine, and in fact exactly how I would recommend people to do thing. It's always helpful to see other peoples solution to a problem. You'll end up in many cases throwing that solution out completely in the end, because it's slow, stupid or outdated. Not every solution you find is going to be good.

But you'll learn much faster this way.

I copy and paste a lot. Both from others and from myself. I don't see the problem with this. In fact every single project I start I start by using a module (ironically but for unrelated reasons) called Paster to create project skeletons. Why would I type in the skeleton code myself?

So you continue pasting. As long as you understand what the code does and why, it's not a problem.

share|improve this answer
11  
+1 for "As long as you understand what the code does and why..." which really seems to be the crux of the issue. –  Steve Evers Dec 31 '10 at 8:54
2  
If you understand it that means no Cargo Cult Programming. –  Malfist Dec 31 '10 at 14:39
show 1 more comment

Just my opinion, (and I'm no expert) but I would have to say: no.

To me a c&p programmer is one who just blindly copies something without understanding why it works.

If you understood why the example works, and had the confidence in your understanding to make modifications, then you are not a copy and paste programmer.

share|improve this answer
2  
+1 for To me a c&p programmer is one who just blindly copies something without understanding why it works. That's what one is to me as well. If you take the time to understand the code and it is no longer "just magic", then you are learning, not copying/pasting. –  Rachel Dec 31 '10 at 17:25
show 1 more comment

In my opinion, you are a copy-paste programmer if you literally copy-paste something in your app and expect it to compile/run without knowing why the code you just copy-pasted works.

If you can tweak the code to fit your needs, then you are not the definiton of a "copy-paste programmer".

share|improve this answer
show 1 more comment

How do you say if a person is a copy/paste programmer ?

Ans: A Smart programmer!
Don't hesitate to steal code (if not violate any licenses and appropriate, we even coin the word code reuse for it).
We are not at school which homework had to do by ourselves.

The best way of code reuse is to include their library
so that you enjoy the upgrade and bug fix from it.

You shouldn't feel guilty about it at all...

share|improve this answer
show 2 more comments

So does this make me a copy/paste programmer? << Not actually!

A copy-paste programmer is the one who steals the code itself, whereas you are merely taking ideas for trivial things in your project. I assume you are using your own logic.

Just chill, and Don't let that guilt build a home inside you brain!

share|improve this answer
show 1 more comment

I got my first computer when I was five (a ZX Spectrum :) and have been programming since then.

When I was five, I was a 'copy only programmer' as there was no copy and paste! I would get a magazine with an article listing the code for a simple program like, 'guess the number'. I would painstakingly copy out every character. Then save it onto a tape and run it. By the 13th attempt, or so, it would run.

Later, I started to create my own programs out of my head. I adopted copy/paste the moment I had Internet. When Google arrived on the scene I did it more.

I will still copy other peoples code and read it / understand it, however, now, I never copy / paste my own code.

I've tended to notice that if you copy / paste your own code bad things happen. For example, you might forget to rename all the variables used, or you're duplicating code that should be refactored somewhere. Inevitably you're running into some bug patterns.

share|improve this answer
1  
Normally I copy/paste for different projects, and only if it's large –  Searock Dec 31 '10 at 15:34
1  
+1 I too started on the ZX Spectrum, copying the listings. I think we all start with copying, the same as in any discipline, we learn by that method, right from the start. –  Orbling Dec 31 '10 at 16:12
add comment

programming(php, asp, jsp) may change, But Logic is more important.

If you Understand the logic behind, you can work on all programming. Np problem if it is Copy/Paste. Understanding is important

share|improve this answer
add comment

Oh you bad bad bad baaad man... Tsk tsk tsk.. C&P is a very very bad act. (If you know what the code is doing and how it's doing it CTRL+C and CTRL+V it) You're a very bad man.

share|improve this answer
add comment

I've never copied and pasted code that didn't also introduce a bug into my system. Just my 5¢.

share|improve this answer
add comment

To me, a Copy/Paste programmer is someone who sees something in another part of the application that is similar to what they need to do, and copies and pastes that code into the section of code they are working on.

Scenario 1: They then leave that code exactly as it is without modifying it, and you end up with exact duplicates of code throughout your application. Not good, but fairly easy to factor our when discovered.

Scenario 2: Find similar code, paste into a new part of the application, and change it a little. Can be factored out when discovered later, but these little difference become a major pain in the butt.

Solution: Factor out a more generic solution (class, component, what-have-you), and use that new component for both places in the application.

What you do -- find code on the internet, paste it into the app, and modify it appropriately -- may be fine as long as your application code ends up a cohesive set, and not some kind of Frankenstein Code. As long as you understand what it's doing, how you to modify it in the future, I don't see a problem. I think most of us google for solutions when we're trying something we haven't done before. One of my pet peeves is when people say, "I can't modify this code, I found it on the internet and don't really understand what it does, so we have to leave it exactly as it is."

share|improve this answer
add comment

No, you are learning, and most people learn through hacking other code.

Eventually you will find yourself looking at APIs most of the time. Call yourself a copy/paste programmer when you copy/past your own code or others' out of sloth.

share|improve this answer
add comment

I always thought a "copy-paste programmer" referred more to the "style" of programming.

For example, a copy-paste programmer might copy paste his own function several times and tweak it a little every time instead of properly designing his program and/or generalizing the initial function more so that the code is present in only one place.

Anyway, this is what I always thought people meant when saying "copy-paste programmer", and by this definition, copy-pasting other people's example code is perfectly fine.

share|improve this answer
add comment

Here's my 5 cents. Being a c/p programmer is to some extent defined by your area of expertise. What I mean is, if you're a web developer, you can find dozens of information about the subject with supporting source codes, etc, and not using this code is silly. But, if you are working in the area of i.e. Real-time systems, EDA, cluster systems - finding a sample code that will save your day is almost impossible, it's much easier and efficient to sit and think about a certain algorithm and implement it by yourself.
If you are a beginner, than of course, the most efficient way of addressing a task is to learn how others have completed it, hence, studying others source code, and using it. That's how I've started, but later, as you mature as a developer, you'll find that most of the available solutions are not that elegant, they have performance issues, or they are simply ugly, and you'll end up writing your own code.

share|improve this answer
add comment

I wouldn't call you a copy-paste programmer. You are not actually doing this blindly (as you said), but actually figuring out what's going on before using the code. There is nothing wrong/harmful in that.

I usually actually type out the code myself, even if it means basically typing it in word for word (or is it character by character for code?). I find that that whenever I copy paste, I often forget exactly how that problem was solved even though I remember the logic behind it. There are a lot of nuances and subtleties that are simply not registered when I just read code, even though I can follow and understand the reasoning involved. Actually typing it out forces me to to confront details, hidden issues and easy to make mistakes that I would otherwise miss.

share|improve this answer
show 1 more comment

People often hunt for almost-solutions in their existing code base, and copy the almost-solution and fix it up. I used to think that such duplicated code was outright bad.

(But I do it a lot, so it can't be wrong! As a practical matter, I'd guess everybody is a copy-paste programmer)

What I now perceive it to be is an means to make programmers efficient in the short term, with negative long term consequences.

What code cloning (copy-paste-edit) does is allow a programmer to pick up a solution to a problem and customize it more quickly, than she could presumably do by writing from scratch. From a (short-term) time and cost point of view, this is pretty much a win.

The problem is that any cloned code comes with the set of bugs and assumptions built into the original copy. When a bug is found in one, or the foundation set of assumptions changes, then all the copies need to be revalidated. And while people seem to know their code is full of clones, they generally don't seem to know if the code they happen to be modifying has a clone somewhere else. So, the clones don't get fixed, and that's that long term negative consequence.

I now think that right answer is that programmers should be encouraged to clone, and some tool should be used to track the location of all clones (since programmers seem unwilling or unable), and tell the programmer when she is modifying one, or let her examine the set before she starts and abstract the clones away.

There's a variety of clone detection tools out there, so there's no excuse for people not tracking them anymore.

(I built one over a decade ago and using it has lead me to this conclusion).

share|improve this answer
add comment

I think reuse reuse reuse is increasingly become the way things are supposed to be done. How much you do that, versus how much you roll your own is probably mainly a function of temperment. By temperment, and well as several bad early experiences, I don't like to copy packages, I'd rather figure out how to implement it myself. But, this obviously has its drawbacks. People like me, will learn a lot about designing/building low level proceedures, but may be hopelessly inefficient building a big app that uses a lot of existing subfunctions that can be found in opensource. If you are on a team, it would be good to have at least one programmer who is of the the roll-hisown type. If you need any novel solution methods, he would be best able to write them. But, you also need people adept at finding, evaluating and integrating existing code as well. I think it ineveitable that as time progresses the C/P activity will gain in importance.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.