upbeat.it

by Cesare Rocchi

Copy and paste mentality

by Cesare Rocchi

Raise your hand if you remember which was the most difficult obstacle when you started programming. I do. It was the difference between ‘=’ and ‘==’. To me they were the same. I remember that to complete a homework I needed a function and it was like one that my mentor already shared with me. So I took his code and, on purpose, exchanged all the occurrences of ‘=’ with ‘==’ and then submitted. My mentor was a super calm and cozy guy. As he saw my code he yelled at me for 10 seconds and then he started explaining me the difference between ‘=’ and ‘==’. I’ll never forget it.

When I started programming I did a lot of cut and paste. The first reason is that typing is boring to me. Ever tried to copy some code from a printed book? Good bless ebooks! So I thought.

The third party code that I copied didn’t do exactly what I wanted. Changing it meant that I had to actually understand it. Having the solution to a similar problem didn’t help, indeed it was an obstacle to me. All the time (and stress) that I saved via copy and paste suddenly was knocking on my door.

Since I started my career my style evolved quite a lot. Now when I see a piece of code I look for inspiration and I end up saying:

"Oh look he used this API to calculate that. Good, I don't have to dig into the documentation!".

or

"Great, so this is the template for this function: step 1, 2 and 3".

Sometimes I still end up copying a few lines. They are usually “timeless” and highly reusable lines, like sorting an array of objects by key. In a word, snippets.

A few days ago Justin Jackson has published an interesting post that resonated a lot with what I wrote above. You can in fact apply a copy and paste mentality to business too.

There are many “successful” entrepreneurs out there publishing posts/books about building a business. Some of them have such an authoritative voice that it’s easy to fall into the copy and paste attitude.

"He/she followed that path and was successful. If I follow the same path I will be successful too."

Much like with code, chances are that:

  • the “recipe” proposed by your hero doesn’t do exactly what you want.
  • You will need to change it
  • To change it you will need to understand it.
  • Parts of the recipe you have copied are now an obstacle instead of an help.

As with code, I have learned to copy just the bits that are “timeless” and reusable. The rest I’ll forge it myself. Sometimes it’s hard, because I feel I could take some shortcuts, but I remind myself that in the long run it will pay off.

What about you? Are you following a similar approach? Or a totally different one? Hit me on Twitter if you wanna chat or write a blog post about it and send me the link. I am very interested in this topic.