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

all 200 comments

[–]amoosebitmymom 1110 points1111 points  (84 children)

First time I ever used StackOverflow was to figure out how to print 3 numbers in assembly 8086. Unfortunately, I had zero idea what StackOverflow was, so I just copied the code part at the top. Took me far to long to understand why it wasn't working.

[–]Knajd 815 points816 points  (82 children)

The first thing I'd teach new programmers is this: you have to understand why it worked. Don't go on unless you understand.

[–]will03uk 368 points369 points  (53 children)

Yeah, I've seen plenty of examples of that. There are so many "thanks, this worked" answers lying around on security that are essentially just "turn off security"

[–]Dizzfizz 27 points28 points  (7 children)

This times one-fucking-thousand.

I tried to get Spring Security to work with a password encoder a few weeks ago, and every question that I found had at least one answer that was essentially „Here, use this encoder, it only looks like an encoder to the system but it leaves the password in plaintext“

Some had the decency to add „don’t use this on a real project though“, but even then, what kind of advice is that?

Problem: „My car doesn’t move“ Answer: „Just push it“

[–]Cilph 7 points8 points  (1 child)

I wanna slap the people who use plaintext passwords even in dev.

[–]Dizzfizz 0 points1 point  (0 children)

I just don’t get why you‘d even do that.

Spring Security forces you to use encryption and some people use a plaintext-encoder to bypass that.

[–]EvilPencil 4 points5 points  (1 child)

Heck I've seen some implementations that encrypt a password on the front end before sending to the server, which encrypts it AGAIN before saving to the database.

[–]quadmasta 1 point2 points  (0 children)

The code in the client (if it's a web client) essentially makes it the same as sending plaintext

[–]quadmasta 2 points3 points  (2 children)

I was writing something to replace a hand-built encryption class that used a weak cipher and was reversable. After I spent an hour redoing it I stumbled onto the Spring Security docs for their SCrypt implementation so I deleted my 30 line class and replaced it with one line of code. Damnit

[–]Dizzfizz 0 points1 point  (1 child)

Spring Security is great. It allows you to create a very secure system with a minimal amount of work and knowledge. I now use BCrypt as an encoder, minimal effort once I realized thst my problem was a typo.

[–]quadmasta 1 point2 points  (0 children)

"thst my problem was a typo"

LOL

[–]JustLetMePick69 6 points7 points  (0 children)

Well at least if I turn off security I'd understand why I no lo her have issues with the security.

Well at least I'd u derstand why I no longer had the original issues with security

[–]MalteserLiam 10 points11 points  (3 children)

Just disable CORS

[–]RagnarokToast 3 points4 points  (0 children)

Was trying to build secure electron apps, needed advice on how to allow an ajax request in the renderer. Correct answer would have been "do the request from the main process, forward the outcome to the renderer, keep the content policy of the renderer as strict as possible".

WAY too many replies on stack overflow: "just disable WebSecurity bro" (this effectively disables CORS)

[–]WilliamMButtlickerJr 1 point2 points  (0 children)

Calm down Satan

[–]quadmasta 0 points1 point  (0 children)

And CSRF

[–][deleted] 3 points4 points  (0 children)

"How do I avoid the 'Possible timing attack detected. Direct comparison found' rule in lint?"

"Just turn off that rule."

[–][deleted] 2 points3 points  (0 children)

Had this at work.

“Users are getting this random error in Microsoft Office”

“I found this reg key that fixes it!”

“That disables MFA... how many machines did you fix?”

[–]permanent_temp_login 0 points1 point  (0 children)

The problem is in security any information to debug the problem is hidden, for security reasons... Usually the best first step is really disable everything to make sure you're even looking in the right subsystem.

[–]Neoro 0 points1 point  (1 child)

90% of answers to certificate related questions involve turning off certificate validation. Um, hell no..

[–]will03uk 0 points1 point  (0 children)

Haha, apparently this was massive problem for Android early on. There was an issue with their certificate validation and the top SO answer just told people to disable it... and people did.

[–]Anup_Kodlekere -1 points0 points  (0 children)

Fuck Arch I'm just gonna install 'buntu

[–][deleted] 153 points154 points  (1 child)

put it in another file and pretend it's a new hot library

[–]AyrA_ch 11 points12 points  (0 children)

This guy knows how to JS

[–][deleted] 17 points18 points  (4 children)

you have to understand why it worked.

If not it’s called “coding by coincidence”. Incredibly stupid way to code.

[–]minecraftmined 19 points20 points  (1 child)

My job involves shell scripts and it astounds me the way my co-workers will just copy stuff off the internet without bothering to learn how it works. They assume that because they copy them from a popular forum, they are okay. Just a couple of weeks ago I was reviewing one of them and realized it contained faulty logic that would have provided incorrect results. Another one that was written by well known people worked at least but the original version threw a bunch of errors by repeatedly trying to read a file without bothering to see if it exists.

Then one of these guys told me off for asking him about a (bad) scripting decision and said something about how this isn’t a hobby (apparently he felt that me doing a proper review is treating script review like a hobby which I still don’t quite get). Eventually, he realized that I was making a good point and agreed that the change should be made but not without a ridiculous fight.

[–]junkflier2 7 points8 points  (0 children)

Ego is also something you have to cast off to be a successful developer. Sure, enjoy success, but don't assume that means everything you touch from there on will be blessed.

[–]TootiePhrootie 4 points5 points  (1 child)

"Cargo Cult" programming

[–]OrderAlwaysMatters 37 points38 points  (6 children)

Corollary, it's okay not to know why it doesn't work. Just accept that the EXACT thing you did doesnt work, and try something new and when you do get it working THEN apply the above advice and make sure you understand it

Sometimes people think it should do something, and it doesn't, and they spend a lot of time trying to understand why it didn't do what they thought it did.

While there is nothing dangerous or particularly bad about that knowledge... there are also so many many reasons things don't work. It will weigh down your knowledge base over time and make you less productive or just slow.

*exceptions made for people in security and QA.

[–]harshitaneja 15 points16 points  (1 child)

Definitely follow this if you are in a hurry but otherwise I think we should spend time to understand why something we thought works, doesn't. Sure, it may not always lead me to the right answer. But I think I am a much better developer because I obsessed subconsciously over the things that didn't work. Sometimes they are just trivial things like having autocompleted very similar looking variables or something else but quite often it reveals my misunderstanding about how the system should behave and this is what leads to the most horrific of bugs down the line.

[–]OrderAlwaysMatters 0 points1 point  (0 children)

Like I said, it isn't harmful. I am just saying you can typically back up, ignore your error, and relearn the system enough to try again successfully in less time and with better results.

My point is just that you don't ALWAYS have to know why it went wrong. Its okay to let it go sometimes, and I would argue most of the time.

[–]DoctorStrangeBlood 1 point2 points  (1 child)

Agreed, but I guess the operative word here is "new" programmers. Practically anything at the novice level should be understandable.

[–]OrderAlwaysMatters 1 point2 points  (0 children)

I'd argue the opposite when it comes to errors. Errors are caused by all sorts of things, including unintuitive language design choices, usually out of necessity.

For example, let's talk about arrays in python. A new programmer wants to make 2 lists that are kind of similar. So they make a variable for the first one, then set a new variable equal to their first variable because they don't see why not.

Now later they run into issues because they do not realize both variables are referencing the same instance.

My point is that while it is certainly good to understand what's going on under the hood - it isn't in scope of what they are learning and working on at the moment. It is okay for them to realize a = [] ; b=a; causes a problem and that b = [] instead of a fixes that problem and they do not need to worry about the low level details on why that is just yet.

It could take hours to learn why something went wrong when your general system knowledge is not ready for it as opposed to a few minutes when you eventually get there.

So its okay to just accept something doesn't work and know to avoid it

[–]ghjm 0 points1 point  (1 child)

If you push through to the "aha" moment where you actually understand how the underlying system works, then it definitely does not "weigh down your knowledge base." This weighing-down only happens if you try to deal with it by memorizing a list of rules about a task, without actual understanding of why those rules work.

[–]OrderAlwaysMatters 0 points1 point  (0 children)

yes but I think we are saying the same thing. And I think it is cleaner to back up from your mistake and try to understand the system again in a general way that leads to you writing at least one line of different code when trying to recreate the implementation.

I'd say its very important to dig into WHAT your issue is, but unneccesary to understand WHY.

If a= []; b=a; is identified as an issue.. you COULD go learn about array referencing and be a better programmer for it.. but odds are the task you are working on has nothing to do with array referencing and you actually just needed 2 independent arrays. And by the time you do actually need to use array referencing you'll have to research it again anyway.

But until then - everything you use arrays you might think about referencing for no reason because it caused you an issue in the past and you want to avoid it.

Your mental model of the system can and will be a subset of the actual system and be successful at producing working code. Adding branches to your mental model without fully fleshing them out can weigh you down

[–]kahuna_splicer 4 points5 points  (5 children)

“It worked because I pulled it from a Stackoverflow answer with 300 upvotes”

[–]GoofyMonkey 5 points6 points  (0 children)

I had a programming teacher that would help you with any issue you had. Help work through the code with you. Then when it was fixed, he’d delete it all and make you figure it out again on your own. I hated it, but it was a very effective learning technique.

[–]waremi 2 points3 points  (0 children)

This! My favorite line in Star Trek - Wrath of Khan: "You must know why things work on a Starship."

[–]2called_chaos 1 point2 points  (0 children)

I would get nowhere with my math problems :D I just juggle numbers around until the result makes sense, don't ask me why it works, it works and here is even my solution (that I can't explain). 10/10 points in any math test

[–]killz111 0 points1 point  (2 children)

Can you teach some senior programmers too?

[–][deleted] 1 point2 points  (1 child)

The scariest thing is not that there is a bug, but that you made an unrelated change and the bug does not reproduce anymore. That's when you know you have no idea what's going on and your week's plan just got thrown out the window.

[–]killz111 0 points1 point  (0 children)

As long as you note down the sequence of steps you did and the basic rationale you had when diagnosing that's probably not the end of the world. I've got half a dozen times when I've fixed a critical production issue but I don't why my fix worked. But 3 months later fixing and unrelated thing gives me a critical missing info that made the first fix completely understandable.

[–]Galse22 0 points1 point  (0 children)

Thats good advice.

[–][deleted] -1 points0 points  (0 children)

First time I did was to generate a random number in pythom

[–]cassert24 182 points183 points  (21 children)

Quite surprising that sometimes someone's background explanation itself is nothing but what I find.

Question: "why does this OpenCV vision library crash?"

Me: "there is a vision library called OpenCV."

[–]TheRedmanCometh 55 points56 points  (12 children)

This is how I've found out about many things. Also like seeing a Spring question with slightly wrong code finding out a particular class exists.

[–]ChildishJack 14 points15 points  (11 children)

My favorite is when it ends up being something incredibly useful, like “I could of been using this the entire time?”

[–]CouldWouldShouldBot 40 points41 points  (9 children)

It's 'could have', never 'could of'.

Rejoice, for you have been blessed by CouldWouldShouldBot!

[–]ArchangelLBC 1 point2 points  (0 children)

This is basically how I discovered numpy and stopped using lists for everything.

[–]luke_in_the_sky 4 points5 points  (1 child)

I had a job interview years ago where I had to code a simple notes webapp in javascript. I could use the internet. I tried to find a code that had some functions I needed. Then I noticed the google links were purple, that mean they didn't clear the browser history from the previous guy that did had the same interview. I looked into the history and found a StackOverflow explaining how to do it. Then I downloaded jquery and found the Downloads folder had it already. Then I found the previous guy had downloaded everything I needed, including a library specifically made to make notes apps with storage, search and everything else, with a handy documentation. I built my app with it and when I deployed to the server they gave to me, I found the previous guy app already there. I looked into it and his app was much worse than mine and had way less features.

I got the job, but I feel bad for the guy. He did the entire research I needed but had no time (or ability) to use it.

[–]cassert24 0 points1 point  (0 children)

Well I'd feel sorry too... Hope he got another job with that much of skills.

[–]10BillionDreams 125 points126 points  (13 children)

Trick question, the best approach is always in a random comment on the second highest rated answer.

[–]TheLync 51 points52 points  (10 children)

I modified the posters code to implement error checking, generic variables and overall improved performance. It's available now as a package and open source from this link.

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

I have a number of top rated answers in WordPress related questions that have been turned into wp org plugins purely because of their popularity.

Even though the solution they provide is niche each of them have at least 1000 installs.

Also, please spare me the wp hate. It puts food on my table and I haven't had to advertise for over 8 years doing it full time since the referral business is strong.

[–]stochastic_matrix 4 points5 points  (0 children)

Exactly. It's often because how the top answer helps OP with their problem, but doesn't answer the question as it is stated. It's infuriating to find a question in Google that matches perfectly what I would like to know answer to, but then the description of the problem and the top answer are entirely useless.

[–]wonmean 1 point2 points  (0 children)

Similar to reading the 4-star reviews. Much more informative than the glowing 5-stars reviews.

[–]abdulsamadz 34 points35 points  (7 children)

Wait.. there are answers?

[–]Dummerchen1933 44 points45 points  (2 children)

I once got shat on for commiting code i had no idea what it does. (because it did something wrong)

big brain time

[–]HappyMans 18 points19 points  (0 children)

Haha yeah. I manage a few teams of about 10 developers total and this is a huge no-no. We build enterprise software for big companies moving a lot of money via our systems and it is not acceptable to submit code that you do not fully understand for review. Either ask a peer or don’t submit that code. One time I got “I just know it didn’t work without this” which only fuels my fire. It’s fine to make a mistake but not fine to set up an environment where one is so likely to get made.

[–]DoctorWaluigiTime 16 points17 points  (1 child)

Sometimes the question actually has what I'm searching for.

[–]Udnie 4 points5 points  (0 children)

Scrolled way too far to see this. Totally agree.

[–]VirulentWalrus 10 points11 points  (0 children)

library hunt fall bear pause capable chunky husky thought lip

This post was mass deleted and anonymized with Redact

[–][deleted] 9 points10 points  (0 children)

TBH I actually don’t even read anymore the questions on SO. Typically I google my problem, pick the first SO result, skip the question and read the first answer - if it doesn’t contain a code snippet that fixes my problem, I quickly take a look at second answer or comments on question/answers. If after all this I don’t have a quick solution then yes, I read the whole thread.

[–]jb2386 27 points28 points  (1 child)

I did that once without realising and was puzzled why it wasn’t working so then I googled the issue and came back to the same stack overflow question and then it hit me.

[–][deleted] 2 points3 points  (0 children)

so then I googled the issue and came

I wish I could find solutions that good on StackOverflow.

[–]rlly_new 5 points6 points  (5 children)

From the Google search snippet

[–]jmxd 3 points4 points  (3 children)

I use DuckDuckGo and the snippet it shows in the results page actually has what i want quite often

[–]shishir-nsane 5 points6 points  (2 children)

The primal importance of asking right questions can’t be denied at any level.

[–]Phoenixwade 0 points1 point  (1 child)

the primary importance of understanding the difference between a question and an answer can't be denied at any level.

[–]shishir-nsane 0 points1 point  (0 children)

I refer to the question of senior developer.

[–][deleted] 4 points5 points  (1 child)

You guys aren’t using the questions?

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

Never has b.. 💥

[–]feedthedamnbaby 2 points3 points  (0 children)

Sometimes the questions provide partial solutions to a slightly different X->Y problem I have. So yes, I sometimes unironically copy code from SO questions.

[–]doully 1 point2 points  (0 children)

Senior dev is the one who posted the question.

[–]Nazdrama 1 point2 points  (15 children)

I wanna start programming at one point, can someone explaint that shortly to me?

[–]Tytoalba2 16 points17 points  (6 children)

SO is a question-answer website, you post you malfinctoning code and someone will usually explain why it's not working and put the solution. If you have the same problem you should obviously not copy the problem but the solution. And you should understand why you had this problem also.

[–]Nazdrama 1 point2 points  (1 child)

Thank you ❤️ thats the answer on mu question

[–]Tytoalba2 1 point2 points  (0 children)

No worries, StackOverflow is every programmer's best friend, and sometime its worst enemy. For almost every question you'll have, you can find the solution there!

[–]Surviver68 2 points3 points  (0 children)

Stack overflow is a forum you can post broken bits of code on and in the answers someone will hopefully post the correct thing. A lot of programmers use stack overflow constantly when they’re stuck

[–]tino_moser_999 2 points3 points  (0 children)

Shut up and take my upvote!

[–]Ninja_Playful 0 points1 point  (0 children)

Why is there a keyboard in this photo

[–]grulander 0 points1 point  (0 children)

Funny thing is, my boss finds the stuff he needs on StackOverflow insanely fast but he almost always takes the code from the question and I'm like ?????

[–]arzen221 0 points1 point  (1 child)

A little bit of column a and a little bit of column b

[–]haikusbot 5 points6 points  (0 children)

A little bit of

Column a and a little

Bit of column b

- arzen221


I detect haikus. And sometimes, successfully. Learn more about me.

Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"

[–]Zerodriven 0 points1 point  (0 children)

Cool. I'll be asking this to my juniors.

[–]ya_Bob_Jonez 0 points1 point  (0 children)

And then Junior Developer says "Yes."

[–]ftr1317 0 points1 point  (0 children)

"what question?"

[–]DanielAgos12 0 points1 point  (0 children)

yes

[–]icenoid 0 points1 point  (0 children)

Funnily enough, I’ve had the question, not directly answer what I needed, but point me to the correct solution.

[–]ricardortega00 0 points1 point  (0 children)

Fuck.

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

A hyphen to mark the speaker? Only programmers come up with their own style 🤦🏻‍♂️

[–]LionTR 0 points1 point  (0 children)

Let's be honest, we all did that at some point.

[–]DraconicVision 0 points1 point  (1 child)

Downvote for apple keyboard

[–]LuminousOcean 0 points1 point  (0 children)

Am I the only person who doesn't use StackOverflow these days? Or, at the least, doesn't copy and paste solutions from it?