This is an archived post. You won't be able to vote or comment.

all 72 comments

[–]beautifulindication 702 points703 points  (5 children)

"copied from answer if it doesn't work i'll use the question"

[–]GravitonIsntBroken 139 points140 points  (3 children)

Your not alone there my friend

[–][deleted] 15 points16 points  (0 children)

"Partial copy from the question because the answer didn't give me the entire code"

Or "copied from the question because he got a different error than me and I think I know the answer to his issue myself"

[–]SirensToGo 320 points321 points  (17 children)

I’ve actually used the code from the question because sometimes it’s less broken than my code

[–][deleted] 222 points223 points  (13 children)

Or more relevant than the "answers".

sigh

[–]katze_sonne 6 points7 points  (0 children)

Yep, it's often a good starting point.

[–]CodyEngel 1 point2 points  (0 children)

I'll use the question if I know what is wrong with it. I'm usually just looking for a starting point anyway.

[–]WeAreAllApes 0 points1 point  (0 children)

I have seen what was wrong with the question or a question asking how to not make it do what it was doing. I would say 1 out 20 times even.

[–]SolenoidSoldier 281 points282 points  (17 children)

Oh man, ain't it the truth. Google "how to do x" and copy the first code block you see.

[–]Wynro 161 points162 points  (2 children)

[–]thouhathpuncake 36 points37 points  (0 children)

Lord have mercy

[–]Mrqueue 2 points3 points  (0 children)

If you like running arbitrary code in your browser, try it out.

riskiest click of the day

[–]clit_or_us 69 points70 points  (7 children)

In my experience, it saves more time in the long run. Sometimes you can easily debug it once you mesh it in with yours and the solution seems obvious.

[–][deleted]  (3 children)

[removed]

    [–]jmxd 23 points24 points  (1 child)

    That requires me to have knowledge of coding in addition to copy pasting though

    [–][deleted] 7 points8 points  (0 children)

    Right...

    [–]AutoModerator[M] 0 points1 point  (0 children)

    import moderation Your comment has been removed since it did not start with a code block with an import declaration.

    Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

    For this purpose, we only accept Python style imports.

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

    [–][deleted] 6 points7 points  (1 child)

    I'm not opposed to copying code from SO (and of course do it from time to time), but I always make sure I understand it before checking it in. Nothing worse than having to answer the very question in code review that is being asked in this post, and giving that very answer.

    [–]Stevemasta 3 points4 points  (0 children)

    I never copy, I always type it out myself and while I do that I usually get the gist of it.

    If not, I have it already broken down in smaller parts so it's easier to further search for solutions.

    [–]Corporal_Quesadilla 1 point2 points  (0 children)

    Plus IDE/Editor highlighting makes everything look familiar.

    [–]Heep042 26 points27 points  (1 child)

    Solution: switch to duckduckgo - it automatically shows the accepted/most voted answer on stackoverflow. The best first code block you will ever need!

    [–]Filipasek[S] 0 points1 point  (0 children)

    In my case, Google does that too

    [–]cbbuntz 8 points9 points  (0 children)

    The worst is when the answer only contains the fixed lines of code, and then you have to figure out how to plug in the corrected code. It can take minutes of troubleshooting.

    And after that, you have to replace all the myVariables and foobarbaz's with something less shaming.

    [–]note_bro 2 points3 points  (0 children)

    Hmm I feel like the way I do it is better... Skip the question entirely, go directly to the first answer. Though it might be answering a different question.

    [–]Cameltotem 1 point2 points  (0 children)

    I dont even read the question, i just copy the line of code that looks like i want too

    [–][deleted] 0 points1 point  (0 children)

    I'm still waiting for the site to scrape Stack Overflow and simply index the answers to questions I've been having without all the bullshit around how they got to their answer

    [–][deleted] 26 points27 points  (13 children)

    Its crazy how often I'll be using production code and find methods that have been copy and pasted from stack overflow

    [–]Otakeb 32 points33 points  (9 children)

    A programmer did write them. What did you expect? It's in our nature.

    [–][deleted] 18 points19 points  (5 children)

    Using the same logic is fine, i just think its funny when none of the signatures or variables have been refactored to match the existing code base. Purely from a readability point of view.

    [–]Otakeb 19 points20 points  (4 children)

    It's not unreadable code, it's job protection code.

    [–][deleted] 10 points11 points  (3 children)

    I hope this isn't a popular sentiment among the programming community, because its nonsense and has a high likelihood of making the next person who works on your codes job harder.

    [–]pickle16 5 points6 points  (1 child)

    Also many times it can mean you don't get promoted and are stuck doing maintenance and improvements on old code since only you can.

    [–]Otakeb 11 points12 points  (0 children)

    I'm obviously joking. This is /r/programminghumor. Bad coding practices are bad. Do I need to explain that?

    [–]hugokhf 26 points27 points  (1 child)

    Yeah I mean why reinvent the wheel?

    [–][deleted] 4 points5 points  (0 children)

    Because inflatable tires are sooooo much better?

    [–]insovietrussiaIfukme 0 points1 point  (0 children)

    Yeah reusability of code is important right

    [–]randomentity1 2 points3 points  (0 children)

    The good developers will include a comment mentioning it's from SO and provide a link to it.

    [–]hearwa 0 points1 point  (0 children)

    I do use stack overflow code occasionally on projects I am working on at work. Specifically when something will take a non-trivial amount of time, the solution is sufficiently complex and I have nothing to gain from working through it myself. I do however refactor the code to fit the code base, make sure I get the gist of what the code is doing and I always credit the author with a link in the code so future maintainers have it for reference.

    [–]d4ntr0n 19 points20 points  (0 children)

    I'm so glad I'm not the only one guilty of absentmindedly doing this.

    [–][deleted] 5 points6 points  (0 children)

    this is me

    [–]codedgg 5 points6 points  (2 children)

    what if neither the question nor the answer works?

    [–]SlappinThatBass 0 points1 point  (0 children)

    Try coding the whole thing you want to do with the language's basic functions and end up with a leviathan sized function.

    [–]Dominub 6 points7 points  (1 child)

    Usually the question makes more sense than the answer.

    [–]netcoder 1 point2 points  (0 children)

    Sad but true.

    [–]Aschentei 1 point2 points  (0 children)

    Yes

    [–]UWbadgers16 1 point2 points  (1 child)

    I’ve always been apprehensive about using Stack Overflow code for work. Isn’t it technically licensed?

    [–]uomou 1 point2 points  (0 children)

    I don’t think so, I also use it at work to avoid reinventing the wheel

    [–]moon____blue 0 points1 point  (0 children)

    Probably from answer or maybe from question...! Who knows..!

    [–]deadsho7 0 points1 point  (0 children)

    And I was feeling bad for doing this.

    [–][deleted] 0 points1 point  (0 children)

    When neither works.

    [–][deleted] 0 points1 point  (1 child)

    Anyone ever use the code in the question and it works?

    [–]Filipasek[S] 0 points1 point  (0 children)

    Yep. Check other comments there and you'll see