DEV Community

Do You Copy And Paste Code?

Milecia on November 29, 2018

You'll be hard pressed to find a developer alive that hasn't copied and pasted code at some point. It might be code from an old project or a snippe...
Collapse
 
romanpaprotsky profile image
Roman Paprotsky

Alt text of image

Collapse
 
flippedcoding profile image
Milecia

😂 That's pure gold!

Collapse
 
romanpaprotsky profile image
Roman Paprotsky

yes, exactly 😊

Thread Thread
 
yoadev profile image
Younes • Edited

I just copy/pasted the image 😂

Thread Thread
 
romanpaprotsky profile image
Roman Paprotsky

Good job man! 😊

Collapse
 
shortstuff81000 profile image
Kelli Jo Isaak

I do that all the time! 😸 I create my websites with an emphasis on accessibility. They all have colored themes that can make the site easier to use for people who are colorblind. The themes are also reversible to accommodate people who need light-on-dark contrast instead of dark text on a light background. 😸

Collapse
 
powepoints profile image
LeadersInFrontOfPowerpoints

The worst projects I've worked on are the ones where I'm required to copy and paste someone else's code with trivial modifications. It's demoralizing and depressing. Once in an emergency I can handle. But as a practice, if someone wants code copied and pasted they should find someone who doesn't care about writing their own code.

Collapse
 
dance2die profile image
Sung M. Kim

How do you feel about using copied code?

I've seen in code comment with just a link to StackOverflow(SO hereafter). When asked why the code was used, the dev didn't know how it worked.

But I could not bring that in a meeting because I was guilty of doing the same, also causing a bug and hindering the bug fix (as I had to understand the code first).

So I "feel" that it's quite bad practice because one might need to change the copy-pasted code not because of a bug but also due to a business logic change. It'd slow down the person who used the code without knowing but also others who have to take it over.

Collapse
 
abbhishek971 profile image
abbhishek971

Copy Pasta... This is one new Pasta flavor and seems to be an interesting one

Collapse
 
lionelrowe profile image
lionel-rowe

Yes, frequently. I usually leave a comment with the URL and some context so I can refer back to it if needed. I very rarely copy without making edits, though — if I needed code that already suited my use case perfectly, I'd import a library instead.

Collapse
 
thomasrayner profile image
Thomas Rayner

I'm personally on board with copying and pasting code with the caveat that you understand it. You could even argue that it's not a huge jump from that to using an OSS dependency. I mean, in both cases you're using someone else's code to accomplish something in your project. In both cases, if you don't understand the code you're using, you're opening yourself up to issues like incompatibility or malicious behavior (like the recent event-stream fiasco).

Reading other people's code is a great way to learn. Including unvetted and not-understood code is asking for trouble, imo.

Collapse
 
apol0x profile image
Apol0x

Hi!
I come from sys-admin and I'm starting to get more deeply involved in the developer world and I'm fascinated by how many people contribute their repositories or code examples to help others. I just think that copying and pasting code is very useful to understand how a language works and to gain fluency programming.
Other hand, reading a lot of documentation in English its help to me to improve my English hahahaha

Collapse
 
flippedcoding profile image
Milecia

Typing it out really does help. Sometimes that's how I figure out what the code is actually doing. But you're right. It's usually never a good idea to just copy pasta. 🙂