9 ms·
Ha, stackoverflow is a great tool, but... the more answers I see on an area I’m experienced in, the more I realize how wrong they can be. Sure, the answer usual
by jordansmithnz 7y ago
Ha, stackoverflow is a great tool, but... the more answers I see on an area I’m experienced in, the more I realize how wrong they can be. Sure, the answer usually gets the job done, but everything else about it might not be right.
If I need to use stackoverflow, these days I make sure I do a few things:
- read a number of answers, comments included. Just because an answer is accepted doesn’t mean it’s the best one
- read API docs for anything I’m unfamiliar with, and make sure I understand how the solution works
- never copy paste; instead use the general idea or concept to rewrite a solution in a safe, future proof manner
- if an answer works but doesn’t feel like the right solution, be prepared to do my own research to find a better approach
Hopefully this results in a better engineered product, but one of the main benefits is learning and expanding knowledge of APIs/techniques.
- zamalek 7y ago> the more answers I see on an area I’m experienced in, the more I realize how wrong they can be The fastest correct looking answers on SO are usually the accepted answers. I read an post or tweet a few years back suggesting that you have the quickest draw if you want SO rep: create a bare-bones answer, with no research, so that it gets accepted. I understand why: my answers have been on the receiving end of this - I spent way too much time and effort answering and my answer dropped into obscurity. That's why I no longer answer on SO.
- megablast 7y agoYou must feel good that you have hours to fix things then. Unlike a large number of people here.
- theshrike79 7y agoThe most important step in my opinion is: Check the date of the question and answer. I've spent WAY too much time banging my head on the keyboard while trying to implement a solution posted 3-4 years ago, which doesn't apply in the slightest for the latest version of whatever I'm doing.
- kitd 7y ago- read a number of answers, comments included. Just because an answer is accepted doesn’t mean it’s the best one Agreed. I find that the "accepted" answer usually gets refined/improved/made more generic after acceptance. This usually means that the "best" solution over all similar problems is usually further down the list of answers.
- plodman 7y agoIsn’t there a “law” that states the best way to get a correct answer is to post the wrong one first? I feel that should be in mind whenever reading through StackOverflow answers. * * Cunningham’s law is the one I’m thinking of. https://meta.m.wikimedia.org/wiki/Cunningham%27s_Law https://meta.m.wikimedia.org/wiki/Cunningham%27s_Law
- aloisdg 7y agoThe accepted answer is the answer selected by the questioner to fix its problem. OP is often not the most knowledgeable person is the room. The real work come from the answer. Show, explain and prove that you understand the problem before answering. It is a good thing to test and to do more research, it is even better to add them to the post. Share your knowledge :)
- matsemann 7y agoWhy not add a fifth point about contribute with a better answer if you know better? It feels wrong looking down on people just trying to help.
- why-oh-why 7y agoThis is the whole point of a community. Especially if you’re sure that the answer is slightly wrong, you can definitely fix it yourself, which is the best part of StackOverflow. There’s no point in even leaving a comment like “X should be X.Y”
- jordansmithnz 7y agoGreat point, this too. Also - if there’s a good answer already there but not accepted, it’s worth upvoting, so that hopefully it becomes more visible to others.
- CJefferson 7y agoThe problem is stackoverflow seems designed to avoid "better answers". Questions are often long abandoned, and the original questioner won't come back and choose a new correct answer. On a rarely looked at question, it would take years for a correct answer to raise up the ranks. I've seen various answers which used cryptography dangerously, and asked if there was any way they could be fixed, and I just got the answer you gave. That shouldn't be acceptable when dangerously bad code is being showed to people.
- rodgerd 7y agoIt suffers from a similar problem to Wikipedia, namely that the likelihood of your information being prominent is a function of how well you rules lawyer, rather than how good your information is.
- SifJar 7y agoIt's worth noting that it is possible to edit other people's answers. So it is possible to correct answers with incorrect or dangerous information. With sufficient "rep" (2000, where an upvote on one of your questions or answers is worth 10), edits don't even require approval from others (before that, they must be peer reviewed before the edit takes effect)
- pjmlp 7y agoThat is how I feel when doing code reviews of offshored projects, problem is, it doesn't scale so the code does the job and stays until something like this blows up.
- rvschuilenburg 7y ago> read API docs for anything I’m unfamiliar with One of the differences i've noticed between myself and some of the junior devs i've worked with. I would usually use the official docs as my first resource, and they would use stack overflow instead.
- avip 7y agoIt's a common use-case that the best docs are provided on some dude's gist or blogpost. Devs and orgs update the code but don't bother with the forgotten docs. It happens all the time.
- epicide 7y agoAnd the original article here is showing a real-world example of the opposite. Namely, "some dude's gist or blogpost [or stack overflow answer]" not getting updated. Not just that they didn't but that they couldn't. Unsurprisingly, which you should rely on depends heavily on context. It takes experience and patience to figure out which one is correct based on circumstances.
- MperorM 7y agoThis is a hard lesson I had to learn as a junior developer. I'm impatient and Stack overflow can often give me an easy solution. But just as often, it can't and I will spend 30 minutes unproductively trying things with little progress. As I become a better developer I become more inclined to spend 30 minutes with the documentation instead.
- tracker1 7y agoDepends on how clear the documentation/usage is... and sometimes you accept that you have limited knowledge and understanding. Either way, it helps to understand what you are doing, and when in doubt look it up.
- nradov 7y agoIf the library documentation isn't clear then that's a clear sign that whoever created it doesn't take quality seriously and you shouldn't use it in the first place. Of course sometimes there's no alternative so you just have to deal with it.
- rubenbe 7y agoI agree: Recently I found an interesting snippet of C code which was using an sprintf to write a string into a char array. Unfortunately, it contained an off-by-one error where the null terminator would be written outside the char. I proposed to fix the answer, but for incomprehensible reasons the edit was rejected (!)
- gambiting 7y agoSO is the worst example of "poop must be delicious - after all, billions of flies can't be wrong!" mentality. As long as the answer is upvoted by enough people, it's accepted as the right one and it takes a titanic effort to correct it, no matter how wrong it is.
- jodrellblank 7y ago> As long as the answer is upvoted by enough people, it's accepted as the right one That's not correct; the questioner can accept any answer, the criteria is that the questioner chooses which answer helped them. There is no connection between votes and acceptance, no claim that "accepted" is endorsement by StackOverflow the company, by subject matter experts, or by "the community".
- Ajedi32 7y agoSee https://meta.stackexchange.com/a/164449/192171 https://meta.stackexchange.com/a/164449/192171 If an answer is factually wrong (as opposed to just poorly formatted or missing a few details), generally its better to leave a comment rather than try to edit it. I agree its not ideal, but suggested edits go into a site-wide review queue, so not everyone reviewing them will necessarily be familiar with C. This makes edit reviews a poor tool for evaluating factual correctness; the comments section and voting system on answers is a better tool for that job.
- crooked-v 7y ago"You can comment" doesn't help when you need a certain rep threshold just to comment.
- moomin 7y agoI'll suggest one more addition to this (and any code you take from the internet): put a comment in saying where you got the idea from (with a link). It can help the next guy out a lot. And you might be the next guy.
- inetknght 7y agoEspecially if it's not a copy-paste job. If there's any adjustments or even a rewrite, the comment should include the reason why the changes were made. The next guy coming along might not realize that changes were needed
- nradov 7y agoIt's usually better to put that information in the revision comments when you commit rather than in the code itself. Otherwise the code accumulates layers and layers of comments over years.
- penagwin 7y agoI feel like it depends - I know I don't just start digging through the commit history of every line I edit. If I'm trying to fix a bug, and only have to change one line for it to start working, and the tests still pass - but that line was there for a reason that wasn't commented (some edge case) - I'll likely miss it.
- jonreem 7y agoPersonally, I've developed a strong preference for putting this type of information as close to the affected code as possible. Immediately next to the affected code is the only place these types of comments have a prayer of being kept up to date. Keeping them in another document, a commit message, or anything similar just results in the content of the message instantly going out of date.
- tracker1 7y agoSo much this... I tend to do this. There are times where I need a limited subset of a library, and will just pull the two classes I need, add the comment at the top, and adjust the namespace.