Good programmers copy, great programmers steal

Just copying the code can be dangerous. However, this can be said about many other aspects in software development, provided that they are handled carelessly. In this post I will discuss issues such as:

  • What does copying code mean in software development?
  • What does correct code theft mean?
  • What are the pitfalls of incorrect copying?

It’s not a secret for any programmers that the sample code that is published as answers to questions here on Stack Overflow often ends up in the final version of programs. Maybe you asked a question, and they sent you an ideal cycle diagram for. Maybe you found an excellent answer, in which part of the code was present with async awaitthat came up for your application.

The last programming book you’ll ever need:

image

When I stumbled upon tweet which talked about the benefits of theft, I thought: can copying code be beneficial?

Note to you, I am not in favor of you indiscriminately copying the code from our Q&A section. Sometimes you may have problems because of this. But, as our guest showed us in the Anna Lytical podcast, this approach can be used to quickly develop functioning prototypes.

If you copy code examples, please leave a link to the license. Depending on the last time the code was edited on Stack Overflow, it is licensed with a version of the Creative Commons license. The most recent codes are licensed by CC BY-SA 4.0, to which reference is required.

Write the code once, put it to work a million times

Copying code from Stack Overflow is a form of plagiarism, that is, duplication of code from one or more projects and its reuse. Looking at which programmer you ask, but it may turn out that in his work from 5 to 10 or even from 7 to 23 percent of the code is copied from some other source. Whether borrowing is made correctly or not is already a question for discussion.

Regardless of the actual borrowing percentage in individual projects, we can say for sure that code duplication is extremely common. Boilerplate code is code that is regularly repeated throughout the project. It is likely that programmers do not type it each time themselves. Libraries such as Lombok make it possible to reduce the need to write a boilerplate, but the fact remains:

  • There will always be parts of the code that will have to appear again and again throughout the project.

AND

  • Due to the fact that these parts will most likely still need small changes, these code fragments cannot be removed into a separate function or dependency.

Speaking of dependencies, we can mention libraries and external dependencies, which are an effective way to reuse code functionality without copying it. It works almost like copying code, with the only difference being that in this case you are not responsible for maintaining the operation of the copied part of the code. Hell, now most of the Internet runs on various platforms and plugin libraries that simplify development. Reusing code in libraries is incredibly effective, as it allows each library to do one thing, and still do it well. And unlike the way all sources should be indicated when writing works in the scientific community, many of these libraries do not need anything from you to indicate that you are programming using someone else’s code or that you use someone else’s code as the basis.

JavaScript Package Manager npm takes it to the extreme. You can install tiny, single-function libraries (some just a line of code) to your project through the command line. You can grab yourself any of over one million free open source packages and start embedding features in your application.

Of course, like any approach, this method also has a minus. After installing the package, you lose some control over the code. Some attackers created really useful packages, waited for them to get a decent download level, and then tweaked the code, to steal bitcoin wallets. We must pay tribute to the npm staff, as they manage to quickly repel such attacks. However, the more external dependencies you have, the more attack area you imagine.

Even Stack Overflow answers are not protected from code duplication. Independent Researcher Discoverl several answers to Stack Overflow, in which the code was copied from other sources. One piece of Java code was found in over 40 responses.

Good artists copy, great artists steal

In the art world, theft is also part of the creation of great creations. I remember how I went to the Van Gogh Museum in Amsterdam and saw his early works there. I was shocked. But then I did not know that in fact those pictures were inspired by Japanese painting and woodcut (woodcut). What I thought was a style unique to his time, was actually part of the history of development, but not the one I was thinking about. Instead of following the path of development that Danish artists had already taken, Van Gogh used the ideas from Japanese prints that he found in Paris (he used the ideas of building composition and the style of brush strokes) and combined them in his works.

Picasso is credited with the saying: “Good artists copy, great artists steal.” Picasso himself drew many ideas from African and Polynesian art and combined them with his sketches. The idea of ​​theft itself is wrong. Indeed, calling someone else’s work theirs is plagiarism. The borrowed thing still belongs to someone else. You copy the style, and it still belongs to the owner. However, to steal, you need to make this idea your own. To declare yourself the creator of someone’s idea is to borrow. But Picasso had in mind that he needed to understand and weave the idea into his work in order to “steal” it. Steve Jobs loved this quote., and Apple was successful under his leadership because they stole ideas, combined them, and improved them.

When you copy code, you run the risk of simply borrowing it. The borrowed code is placed in the project completely if it is well embedded and does not cause errors, but it can contain bugs or can be created by cybercriminals with the possibility of using for their purposes, which you will not know about. The number of risks associated with incorrectly copied code (or copied as amended) is huge. In fact, complaints of duplicate code can track the plagiarist. If you do not understand the code, you are highly likely leave holes in protecting thatthat originally was supposed to be just a demonstration of the concept. Even the most copied piece of code on Stack Overflow is not deprived of a bug.

On the other hand, when you steal code, you definitely know what it does. Its core and its features fit into your own code. If you can write it again from memory, then this is a sign that the code is stolen correctly. This means that code rework has given you more than just a copy. She gave you something new and original.
So yes, steal the code. Take it, understand and apply in your projects. Make it yours. You can gain experience, improve your projects, and maybe even your resume (aka your ctrl + C ctrl + V). But if you copy without an absolute understanding of the newfound code and what it does, you run the risk of making your own code worse.


image

Learn the details of how to get a sought-after profession from scratch or Level Up in skills and salary by taking SkillFactory online courses:


Read more

  • 450 free courses from the Ivy League
  • 30 life hacks to complete the online course

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *