r/programming • • Nov 28 '15

Coding is boring, unless…

https://blog.enki.com/coding-is-boring-unless-4e496720d664
671 Upvotes

390 comments sorted by

View all comments

285

u/[deleted] Nov 28 '15

"...50% of my code was a direct copy/paste of Stack Overflow..."

Huge red flag on so many levels. Stopped reading after this.

73

u/Detective_Fallacy Nov 28 '15

I think that number might have been hyperbolic. Well, I hope so.

39

u/brunoma Nov 29 '15

Yes, it was hyperbolic!

DISCLAIMER: I'm the author, and I happen to be a big fan of StackOverflow, which has taught me a lot.

I thought a big round number like "50%" would have made it clear enough, but I was wrong. (Thanks DualRearWheels for flagging! I've added a note to clarify).

The main point of this section was to say that the "quantity of code" writen by a developer is a bad proxy for the "amount of interesting things learned", especially when there is lots of mechanical copy/paste involved. Maybe it's a platitude to some, but worth tracking in a "boredom checklist" IMHO.

8

u/capitalsigma Nov 29 '15

This was also a red flag for me, the whole paragraph:

Because 50% of my code (hyperbole intended!) was a direct copy/paste of Stack Overflow. And another 40% was a copy/paste from other scripts. Either my colleagues’ scripts or my own. It became repetitive. And there was little creativity or learning involved.

That says to me that your internal infrastructure is bad and you're resolving problems that have already been solved. I don't see how there is a way of reading it that isn't an indictment of your codebase rather than your job.

→ More replies (4)
→ More replies (1)
→ More replies (8)

19

u/anENORMOUSchicken Nov 28 '15

Yeah, and while I like the idea of 3 months stints so code is always new and exciting, it always seems like the last person who rode in and out in 3 months is the one who introduces all the small subtle bugs because they didn't quite understand how something worked fully (I have definitely been guilty of this too...)

81

u/Kminardo Nov 28 '15 edited Nov 28 '15

I might be going against the grain here, but I don't think copy pasting stack overflow is all that bad - as long as you know what it's doing and where it fits into your application.

143

u/twbarber Nov 28 '15

I think the implication is that in copy pasting, you often don't actually have a full grasp of what's going on. Especially if it's anywhere near as frequent as "50%".

24

u/Kminardo Nov 28 '15

Well that's true. But if your putting code into your projects that you're not sure what it's doing (regardless of the source) you have a bigger issue on your hands than copy pasting SO :)

3

u/onFilm Nov 29 '15

The problem here is that people have different levels of 'copy pasting' from stackoverflow. Some copy and paste small snippets or function names of specific languages they're working with since it's hard to memorize everything all the time. Others I'm sure go ahead and copy large programs and modify it to their needs.

14

u/[deleted] Nov 28 '15

I think the implication is that in copy pasting, you often don't actually have a full grasp of what's going on. Especially if it's anywhere near as frequent as "50%".

How does this differ from using a library or a framework?

39

u/missblit Nov 28 '15

Often SO snippets are designed to clearly illustrate some point in particular, perhaps at the expense of security, flexibility, or correctness.

Once integrated into the codebase the snippets need to be maintained by hand. No one else will update them or provide bugfixes. It's hard to maintain code you don't understand.

A framework will (hopefully) be maintained by whoever's responsible for it. One also (hopefully) at least understands how the functions they use from a framework are supposed to behave.

Frameworks aren't perfect either, and people have been bit in the past by misplacing trust in them or overly relying on them without understanding them, but it's like night and day compared to having a codebase full of random snippets you don't understand.

There's also some IP concerns when half your codebase is derived unedited from stackoverflow. With a framework the copyright lines are a lot clearer.

5

u/d03boy Nov 29 '15

Well yeah, you copy and paste the snippet and then modify it to your needs. Obviously you won't get very far taking it verbatim.

11

u/[deleted] Nov 28 '15

A lot (but certainly not all) of major libraries have more rigorous testing, more official reviews, etc. Anyone can write a chunk of code on SO, but it generally takes more than that to get a PR accepted on GitHub.

5

u/twbarber Nov 28 '15

It's similar in that it's someone else's code your using as part of your own, but I think the similarities stop there. The purpose of Libraries and Frameworks is to abstract functionality into an easy to use package. You have intentions when making calls to a library and you understand by means of documentation what the response will be and how it fits what you're looking for. Libraries also prevent code repetition, which the author clearly doesn't care about when he says "And another 40% was a copy/paste from other scripts".

I'm not saying referring to SO is bad, and we've all taken snippets from there, but when he says that 50% of his code is taken from forums, credibility dwindles. Maybe there already are libraries that exist to solve this problem, and he's using SO answers instead of finding a better solution.

→ More replies (1)

17

u/serrimo Nov 28 '15

Then don't literally copy and paste. Recode it, even verbatim if needed.

Actually typing in some lines of code forces your brain to reason about it. I find this simple exercise to help me really understand the code.

→ More replies (2)

2

u/[deleted] Nov 28 '15

Unless someone has run it though https://github.com/reinderien/mimic

2

u/ExplosiveNutsack69 Nov 29 '15

Yeah but that never happens. Never have I copy pasted something because I understand what it does completely and I'm just too lazy to write it myself. I doubt I'm alone in rewriting it all (at LEAST, writing the same code yourself instead of copying).

→ More replies (1)

12

u/rollducksroll Nov 28 '15

He wrote this as a negative. In some systems, boilerplate IS required and there's not available flexibility to avoid it.

If you read the paragraph, he's saying it was bad that he was doing this. What's wrong with that?

15

u/kupiakos Nov 29 '15

"Stopped reading after this" is not giving the author a chance to explain themselves. Stopped regarding /u/DualRearWheels.

→ More replies (3)

6

u/AccusationsGW Nov 29 '15

I hope I never work with someone like you again :)

3

u/[deleted] Nov 28 '15

was a code monkey working with one of those Wordpressy things. at one point I realized that it's faster to look up things on StackOverflow than to find the relevant portion in a file out of many files.

2

u/jgbradley1 Nov 29 '15

I feel (hope) that he was over-exaggerating a little here.

4

u/BlindTreeFrog Nov 29 '15

I stopped reading at "no one works on the same code for more than 3 months". I don't think I've ever worked on a quality product where three months was enough to ever understanding the product well enough to make quality contributions.

OK, that's not true, I did with 2 projects, both were short term contracts and both were products that only did a very specific and terribly simple thing. Nothing you would build a business around.

→ More replies (4)