<p>I let the kids cut and paste code but with the following caveats:</p>

<ul>
<li>They must cite the source (be it a classmate, another student or a site like StackOverflow)</li>
<li>There has to be enough of their project that is their own code to show mastery of whatever the assignment's all about</li>
<li>At times, I encourage them to use others code (and libraries) to enhance their projects, that is, add features that they otherwise wouldn't have had</li>
</ul>

CC BY-SA 3.0
2017-06-22T18:15:42.590Z
I'd add the caveat that if the assignment is to "write code that does X" they can't go acquire code that does X for them. E.g. if the assignment is to write a bubble sort function, they shouldn't be hitting up Stack Overflow for "bubble sort [language]." If a section of the assignment can be completed by utilizing code written earlier in the semester, then getting that segment off SO is fine too (I certainly can't write a merge sort algorithm from scratch, but I need one for project Y, so why not grab it from somewhere else?).
Draco18s no longer trusts SE
CC BY-SA 3.0
2017-06-16T00:34:40.507Z
2017-06-16T15:29:28.510Z
2017-06-16T15:29:28.510Z
Mike Zamansky
<p>I think it is fine, as long as it isn't an essential part. It saves time, and the students can learn from professionals, and can learn new ways of doing something that they never would have thought of. Also, it helps you become a more efficient coder, and if you borrow someone else's functions that is more efficient it makes the rest of your program faster, and it saves a lot of time that could be spent on the main goal, not just some function that was already created before. Don't reinvent the wheel!</p>

CC BY-SA 3.0
2017-06-16T00:56:49.930Z
2017-06-16T00:56:49.930Z
Noah Cristino
<p>In my class, the only rules I set are that kids may not give code to each other, either directly or indirectly.  I also set a "rule of thumb" that if student A needs help from student B on a portion of a lab, student B must have finished that portion, and may look at student A's (relevant) work, but that A may not look at B's work.</p>

<p>Part of the logic here is that I already consider labs to be "suspect" with regards to plagiarism, so the giant brunt of their grades come from tests and quizzes.  The labs, then, are primarily a tool that the kids should use to prepare for the assessment.  I explain this to them often, and point out that not fully understanding their own lab is a great way to shoot themselves in the foot.</p>

CC BY-SA 3.0
2017-06-16T00:50:44.597Z
2017-06-16T00:50:44.597Z
Ben I.
<p>I don't think that student learn that much from just running someone else's code without going through it. </p>

<p>Copy &amp; pasting can be really useful for sharing code that has been deliberately 'broken': you can demonstrate / explain code that is working and then introduce deliberate mistakes for students to find and fix when they copy / paste.</p>

<p>That way they get the speed advantages of copy / paste but they also have to engage their brains whilst getting experience debugging. </p>

<p>Alternatively, you can give students code to copy that they then have to comment / adapt / extend.</p>

CC BY-SA 3.0
2017-06-16T10:09:13.590Z
2017-06-16T10:09:13.590Z
pddring
<p>I'm late to the discussion, but here are two reasons against copying and pasting code:</p>

<ol>
<li>I believe something is lost when you simply copy and paste code. They say that to learn a definition of a word, you read it, say it, and write it. So I think typing code definitely adds value, especially when IDEs like Eclipse have autocomplete and syntax checking. Typing is a learning experience.</li>
<li>Unless you are copying from a raw format, copy and paste could bring in invalid characters. For example, try copy and pasting <em>"hello world"</em> from Microsoft Word to your favorite code editor. You'll see invalid double-quote characters pasted.</li>
</ol>

CC BY-SA 3.0
2017-07-12T14:14:01.087Z
2017-07-12T14:14:01.087Z
Edwin Torres
<p>Item #2, a form of code re-use, especially if it is tested known working lines of code, is usually considered to be a good software engineering practice.</p>

<p>Copying a line or two from the official documentation might in some cases be considered the proper way to learn or to code.  Some professional IDEs do this automagically in the auto-complete hints.</p>

<p>Copying from a web search or stackoverflow requires supervision or auditing.  The instructor needs to confirm that the student understands (what it does, the algorithm, etc.) and has checked what they are copying against more official (for the language, library, etc.) documentation.</p>

CC BY-SA 3.0
2017-06-17T20:41:06.613Z
2017-06-17T20:41:06.613Z
hotpaw2
<p>I'm curious to hear people's experiences with allowing (or disallowing) students to use copy and paste in code when learning as beginners.</p>

<p>I feel like there are two kinds of copy/pasting.</p>

<ol>
<li>Copying code you found somewhere in docs or on the internet and pasting it into your code</li>
<li>Utilizing copy paste with your own code to write similar code more quickly</li>
</ol>

<p>I see some upsides and downsides to both, so I'm wondering what other instructors have learned.</p>

<p>e.g.</p>

<ul>
<li>Upside to allowing it. It's a useful tool for moving quickly and everyone who writes code professionally would use it.</li>
<li>Downside: students who are beginners could really use the practice typing everything out</li>
<li>Downside: it makes it much easier to copy code you find somewhere without needing to understand it.</li>
</ul>

<p>What are other instructors' experiences and insights? Do you allow your students to use copy and paste?</p>

CC BY-SA 3.0
2017-06-16T01:24:47.273Z
This question should not be closed; it is asking for how folks think through their copying policy on labs. It certainly falls under [good subjective](https://stackoverflow.blog/2010/09/29/good-subjective-bad-subjective/) in my book.
Ben I.
CC BY-SA 3.0
2017-06-16T14:01:07.253Z
Professionals should not be copy-pasting random code - this has all sorts of licensing and copyright implications.
Sean Houlihane
CC BY-SA 3.0
2017-06-16T16:03:51.303Z
Sean, sorry to be unclear here -- all I meant by that is that professionals copy from within their codebase all the time -- for example, when I'm making a new page on our website that's similar to a page we already have, I start off by copy/pasting the other page and making changes--in any case, this is all also part of the fuzziness and clarity that I think needs to be discussed and taught to new programmers.
Zach Galant
<classroom-management><plagiarism>
Thoughts on copying and pasting code?
# Thoughts on copying and pasting code?

(Asked by: username_0 on 2017-06-16)

I'm curious to hear people's experiences with allowing (or disallowing) students to use copy and paste in code when learning as beginners.

I feel like there are two kinds of copy/pasting.

1. Copying code you found somewhere in docs or on the internet and pasting it into your code
2. Utilizing copy paste with your own code to write similar code more quickly

I see some upsides and downsides to both, so I'm wondering what other instructors have learned.

e.g.

* Upside to allowing it. It's a useful tool for moving quickly and everyone who writes code professionally would use it.
* Downside: students who are beginners could really use the practice typing everything out
* Downside: it makes it much easier to copy code you find somewhere without needing to understand it.

What are other instructors' experiences and insights? Do you allow your students to use copy and paste?

**Tags:** classroom-management, plagiarism

> **Comments:**
> **username_1**: This question should not be closed; it is asking for how folks think through their copying policy on labs. It certainly falls under [good subjective](https://stackoverflow.blog/2010/09/29/good-subjective-bad-subjective/) in my book.  
> **username_2**: Professionals should not be copy-pasting random code - this has all sorts of licensing and copyright implications.  
> **username_0**: Sean, sorry to be unclear here -- all I meant by that is that professionals copy from within their codebase all the time -- for example, when I'm making a new page on our website that's similar to a page we already have, I start off by copy/pasting the other page and making changes--in any case, this is all also part of the fuzziness and clarity that I think needs to be discussed and taught to new programmers.  

---

## 6 answers

### Answer by username_3 on 2017-06-16. Score: 6

I let the kids cut and paste code but with the following caveats:

* They must cite the source (be it a classmate, another student or a site like StackOverflow)
* There has to be enough of their project that is their own code to show mastery of whatever the assignment's all about
* At times, I encourage them to use others code (and libraries) to enhance their projects, that is, add features that they otherwise wouldn't have had

> **Comments:**
> **username_4**: I'd add the caveat that if the assignment is to "write code that does X" they can't go acquire code that does X for them. E.g. if the assignment is to write a bubble sort function, they shouldn't be hitting up Stack Overflow for "bubble sort [language]." If a section of the assignment can be completed by utilizing code written earlier in the semester, then getting that segment off SO is fine too (I certainly can't write a merge sort algorithm from scratch, but I need one for project Y, so why not grab it from somewhere else?).  

---

### Answer by username_5 on 2017-06-16. Score: 4

I think it is fine, as long as it isn't an essential part. It saves time, and the students can learn from professionals, and can learn new ways of doing something that they never would have thought of. Also, it helps you become a more efficient coder, and if you borrow someone else's functions that is more efficient it makes the rest of your program faster, and it saves a lot of time that could be spent on the main goal, not just some function that was already created before. Don't reinvent the wheel!


---

### Answer by username_1 on 2017-06-16. Score: 4

In my class, the only rules I set are that kids may not give code to each other, either directly or indirectly. I also set a "rule of thumb" that if student A needs help from student B on a portion of a lab, student B must have finished that portion, and may look at student A's (relevant) work, but that A may not look at B's work.

Part of the logic here is that I already consider labs to be "suspect" with regards to plagiarism, so the giant brunt of their grades come from tests and quizzes. The labs, then, are primarily a tool that the kids should use to prepare for the assessment. I explain this to them often, and point out that not fully understanding their own lab is a great way to shoot themselves in the foot.


---

### Answer by username_6 on 2017-06-16. Score: 1

I don't think that student learn that much from just running someone else's code without going through it.

Copy & pasting can be really useful for sharing code that has been deliberately 'broken': you can demonstrate / explain code that is working and then introduce deliberate mistakes for students to find and fix when they copy / paste.

That way they get the speed advantages of copy / paste but they also have to engage their brains whilst getting experience debugging.

Alternatively, you can give students code to copy that they then have to comment / adapt / extend.


---

### Answer by username_7 on 2017-07-12. Score: 0

I'm late to the discussion, but here are two reasons against copying and pasting code:

1. I believe something is lost when you simply copy and paste code. They say that to learn a definition of a word, you read it, say it, and write it. So I think typing code definitely adds value, especially when IDEs like Eclipse have autocomplete and syntax checking. Typing is a learning experience.
2. Unless you are copying from a raw format, copy and paste could bring in invalid characters. For example, try copy and pasting *"hello world"* from Microsoft Word to your favorite code editor. You'll see invalid double-quote characters pasted.


---

### Answer by username_8 on 2017-06-17. Score: 0

Item #2, a form of code re-use, especially if it is tested known working lines of code, is usually considered to be a good software engineering practice.

Copying a line or two from the official documentation might in some cases be considered the proper way to learn or to code. Some professional IDEs do this automagically in the auto-complete hints.

Copying from a web search or stackoverflow requires supervision or auditing. The instructor needs to confirm that the student understands (what it does, the algorithm, etc.) and has checked what they are copying against more official (for the language, library, etc.) documentation.


---

