I read an article the other week talking about computer science students getting into trouble because they had “lifted” some code. I know that taking credit for someone else’s work is wrong, but I have to admit that I lift code all the time.
Why I steal code
I do this for a couple of reasons. One is for consistency. If I am working in a mature code base, I will want to make any code I write consistent with the code already present. I may copy variable names verbatim if I am doing something similar. I may cut and paste snippets of code if needed, and it isn’t something that should be factored out into its own function.
The other reason I will steal code is if I am doing something for the very first time. And I need to look at a working example to get me going. I will visit Stack Overflow and lift code “whole cloth” and use it in my own program. I see nothing wrong with this, and I believe my employer would rather me do that than waste time beating my head against a wall trying to create something from scratch when there is no need. Professional developers, for the most part, are an accommodating group. The entire purpose of sites like Stack Overflow and Java Ranch is to help each other out and post code examples to help solve a problem someone else is asking about.
Learning to steal early
For my senior project when I was attending NC State University (back before the earth cooled), I lifted one of the major functions of the code from someone else. I was working with a team, and we were simulating the life-cycle of the Mexican Bean Beetle on different crops. We were doing this in conjunction with the entomology department. As part of this, we had to generate real-world temperatures and rainfall for our given area. Somehow I was able to locate FORTRAN code that would do this given a latitude and longitude as input. We used that code as one of the major components of our simulation.
When we presented the project to the professor and class, we didn’t make any bones about what we did. I even told them that I couldn’t explain how that code worked because all of the comments were written in French.
Nobody got upset, and if I remember correctly we got a high grade on the project. One of the few high grades I got.
Is stealing okay?
I know that you have to learn yourself, and a lot of that comes from writing your own code. But I hope schools teach the things people need to know once they are out in the real world. Out in the real world, people are stealing code all the time. And as far as I know, nobody thinks it is a problem.
What are you thoughts?
About the picture: The picture was taken on a beach in Costa Rica. The monkey was looking to see if there was anything worth stealing in our back pack.