What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 128 Stack Exchange communities.

Hope this is on-topic, seems meta-ish.

I would like to address the issue of mysql_* functions; for the sane many of you who don't bone up on your PHP doctrine, a little back story. The notorious mysql_* family of functions are related to database access and are set to be deprecated in the near future. The official documentation lists them as "discouraged", and recommends using PDO. The party line is to SHUN.

In a wider context, this sort of situation may exist for other tags, and it boils down to the same thing.

Currently, many seasoned users crusade against these mysql_* functions, leaving copy/paste comments on every question even remotely referring to these database pariahs and directing users to read articles advocating and demonstrating PDO. Others work it into their answer. To these programmers, I can only say "thanks" -- every new tutorial or Q/A on the internet that uses the most up-to-date practices helps wash out the mountain of outdated code using the doomed old functions.

But. If you look at the last question there, you note that though the answerer did disclaimer against mysql_*, they used the deprecated method in sample code to form their answer. The disclaimer is meaningless, but the answer can be defended by saying "I told them about the right way, then showed them the wrong way", or "the answer is based on THEIR code". Perfectly true. I compare this to stopping someone from driving a nail with a glass bottle. You tell how great hammers are and that they are the tool for the job (without actually producing one for inspection). But then you come back, like Colombo, and remember to mention that one could wrap a towel around the glass, preventing a horrible cut when the bottle breaks. You then hand them a towel.

The first point of this post is to put forward a premise: as a Q/A site, StackOverflow exerts a major influence over the adoption of one particular practice or another by the content of answers. Answers here today are Google search results for next month's rank greenhorn. The second point here is the idea that, given the former, we must be more proactive in advocating best practice in the content of all our answers.

Every /mysql_* question that is posted (and there are several hundred posted a day) have the potential to encourage or discourage best practice. Is it appropriate to downvote an answer for simply referring to mysql_* (except, of course, to discourage it)? Delete the answer? Seems extreme, but I feel we have a role to live up to -- this is what separates the StackOverflows from the w3Schools and bottles from hammers.

Hammers, hammers for everyone, I say!

Agree? Fine -- how? Disagree? Why?

share|improve this question
1  
Uh, the last answer used mysqli_* which is a recommendation... am I missing something? –  Wesley Murch Sep 12 '12 at 1:01
    
Oh, yep, good call. I picked the wrong example. Will correct -- it isn't hard to find. I've done it myself! –  Chris Sep 12 '12 at 1:06
1  
Well in any case, you can downvote if you want, if you really think it makes the answer a bad one, but flagging is unnecessary and deletion is too extreme. Not sure what else you're suggesting. Actually it would be more ironic if you just left one of those comments. –  Wesley Murch Sep 12 '12 at 1:11
    
Well I wouldn't worry about search results being a big problem people seem to simply ask instead of searching. Even on meta –  Some Helpful Commenter Sep 12 '12 at 2:32
    
I did search, and read all of those threads. ;) I wanted to discuss the philosophy of the concept, especially the idea that StackOverflow is (or rather, can be) a major influence on the adoption of new language features, and whether answers using older practices can delay the adoption –  Chris Sep 12 '12 at 2:33
    
Hammers are illegal in my country, but glass bottles are quite easy to come by. Am I not allowed to drive nails simply because the preferred method is not available to me? –  Jim Sep 12 '12 at 2:55
    
@Jim you know you should just use an old shoe instead –  Some Helpful Commenter Sep 12 '12 at 2:58
    
I live on a small tropical island - we have no shoes.... –  Jim Sep 12 '12 at 2:59
3  
My point being, @SomeHelpfulCommenter, is that sometimes we need to use known bad practices or hacks because of various environmental constraints. Educating users on the best practice is all well and good, but if it is not plausible for them to solve their problem in any way other than what they are trying, it does no good (although hopefully they will expain that they only have a nail and a glass bottle, and nothing else) –  Jim Sep 12 '12 at 3:01
    
@Jim Would you say that the group of people faced with that situation are very likely to overlap with those that don't understand the difference? I'd say not -- if a beginner is in an esoteric situation, he's probably facing an XY problem. He can and should upgrade, he's probably creating the problem rather than being constrained to it. A more advanced user is more likely to be in that position for a reason, but they'll already know what to do. Our biggest answer-reading demographic is not so much the latter; they'd read the docs –  Chris Sep 12 '12 at 3:59
    
@Jim Here's a similar sentiment that came out of a nasty episode where some people actually tried to implement what Chris is suggesting. What is it with about PHP that makes people what to do this. Maybe its because instead of glass bottles and old shoes they have double-clawed hammers –  Some Helpful Commenter Sep 12 '12 at 5:44
add comment

2 Answers 2

If you look at the last question there, you note that though the answerer did disclaimer against mysql_*, they used the deprecated method in sample code to form their answer.

Perfect

The disclaimer is meaningless

Not at all

but the answer can be defended by saying "I told them about the right way, then showed them the wrong way", or "the answer is based on THEIR code".

Sounds like a spectacular defense (the second half, anyway)


Fluffeh's answer covered most of what I wanted to say, but focused more on "these guys are noobs anyway, don't strain them" instead of "they might have a good reason they don't want to get into". A spectacular number of forums answer the question "I'm using widget X to do Y and it's not working" with "wait, you're using widget X? WTF are you thinking?". They're under the impression they persuade the impressionable beginner into abandoning widget X. Instead, the poster just sighs and leaves to find somebody who will actually answer their question

My answer to "how do we answer questions that do things wrong" has been the same forever: tell them, in great detail if you like, just how wrong they're doing things. Then tell them how to do it anyway, because they might have a very good reason. You can even post both ways if you're ambitious, but if they're going to learn PDO they're going to do it from the docs, not from your random SO answer. Everything outside of the actual question that can be ignored generally should be

share|improve this answer
    
Thanks for the response. I appreciate answers that do include a disclaimer, or even the ambitious "double-answer" (what I do, myself), then there's those that only answer the question and don't mention the better practice. Fair to downvote those, in your view? –  Chris Sep 12 '12 at 5:13
    
@Chris I don't, but that's up to you; I just leave a comment. The downvote tooltip says "this answer is not useful", so I usually only downvote things if they're actually wrong –  Michael Mrozek Sep 12 '12 at 5:55
add comment

You can't force someone to answer using the latest and shiniest methods. Most often, the mysql questions are being asked by folks just on the verge of starting out in some programming - and you guessed it, they googled for a tutorial, came across some old document and BAM! they suddenly have code that mostly works. An answer to a question like this, using something that is totally different to the code that they are using is certainly not intuitive and would only help a few people. Most of the new programmers probably wouldn't even understand it - they have probably spent the last three hours trying to make heads or tails of the 50 lines of PHP that they wrote and altered from the tutorial.

Most of questions in this bucket boil down to:

  • My code has an error that I don't understand
  • I just want it to work
  • I want to know the time, not how to make a cookoo-clock

Most of the answers in these questions point out the exact error. Including a caveat in the answer or a comment telling them about PDO is a good thing, it lets them know about the current and safer technology (which obviously wasn't in their tutorial) - but imagine that someone is forced to use an old PHP install, a ver 4.x.x - answering with 5.x.x functions isn't going to help them either - but they are the most up to date.

Lastly, if someone is asking a question like this, don't you think they are more likely to be more open to a comment suggestion moving to PDO if the answer first solves their problem? Won't they think Hey, this person solved my issue, and they suggest I should look into PDO. I better click the link they provide to see what it is about... than if the answer is another 50 lines of code that they have no idea about and looks like spaghetti to them?

The best answers are ones that are correct and that the question asker can understand. An answer that is perfectly correct, but the question asker cannot understand isn't a good answer. It might be correct, but it isn't great.

share|improve this answer
1  
philosophy because I don't propose that we force anything. However, we can use the downvote system to encourage good practice over bad, and I still think that the analogy with the bottle holds true. You make a point about an answer that does not directly address the narrow problem in a question, BUT, I think it is fallacious to say they "won't understand" PDO. They're learning -- they have to learn something new no matter what. When we contribute to the 3mil + Google results with wrong information, how useful is it that we answered that one guy's specific question? –  Chris Sep 12 '12 at 2:17
1  
The point "StackOverflow exerts a major influence over the adoption of one particular practice or another by the content of answers" is also important -- our role as teachers, I feel, demands that we teach them how to fish, not hand them McDonald's fillet of fish. That might mean that we don't tell them how to fix their broken code with bad practices, but instead lead them down a totally new path using best practices. –  Chris Sep 12 '12 at 2:21
1  
@Chris I totally agree with you on being the best you can be and often try to write answers with that in mind (A few examples: stackoverflow.com/questions/11821933/… and stackoverflow.com/questions/11755832/… I even spent a few hours in a chat with the chap) but what I am saying is that you cannot force everyone to stand up to the same high bar you set for yourself. If anything encourage people to write good answers by upvoting the best ones. –  Fluffeh Sep 12 '12 at 2:56
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .