Question about what is considered original code and 'less' original code

As I continue to look for help with coding, I have realized that I don’t have a firm understanding of code that is considered to be original and ‘less’ original. By ‘less’ original, I mean bits and pieces of code taken or modified from answers provided by users on forums (e.g., Stack Overflow), websites, and blogs.

I imagine the most experienced coders can spot code that has been spliced together. What would send up a red flag to those who are evaluating my code and considering hiring or working with me? And, is there a general rule of thumb that I can follow (e.g., If taking code from another, avoid using more than [#] statements in a row)? Thank you for the advice.

The truth is that all professional coders are going to cut and paste in code from some other source. It happens. You don’t want to spend too much time to figuring out that algorithm so you check Stack Overflow. You are implementing a new library so you cut and paste the example from their web page.

I don’t think there is anything wrong with that. The important thing is, Do you understand how it works?. Even when I’ve cut and pasted something, I usually have to go through it, make sure I understand how it works, clean it up, rename some variables, get rid of some things, add some things. But if I don’t understand how it works, it doesn’t go in my code until I do.

Is it noticeable? Helping some people in this forum, I’ve been suspicious a few times. Like when people have CSS in their HTML file and their CSS file, same for JS. Sometimes they have variables that aren’t used for anything and seem to be an artifact of some leftover functionality that has nothing to do with what they’re doing and the formatting and naming conventions are strikingly different. That makes me suspicious.

But professional coders cut and paste all the time. As long as you know what it’s doing, and you’ve gone through it line by line - I don’t think there’s anything wrong with that. And if you clean up the code, and adjust it to your naming/formatting conventions, then it is undetectable.

Given any algorithm, if enough coders try it, many are going to come up with the same solution. Some are going to be the same, character for character. Take a look at solutions of sites like Code Wars and you can see that. But obviously large programs are going to differ. Cutting and pasting a large program is going to be obvious, but little bits here and there - that’s just research.

2 Likes