There is an old adage, "There are no stupid questions...." What happens in the ellipsis at the end of that adage varies a lot, but the adage always starts with the same line.

Here is a very simple synopsis of the XY problem:

You want to do X, and you think Y is the best way of doing so. Instead of asking about X, you ask about Y.

On Stack Overflow, there is an overflowing abundance of the XY problem. http://www.perlmonks.org/index.pl?node_id=542341

And there are a collection of people who will willingly and wholeheartedly give an answer to Y, without a thought to what X is.

I am an IRC operator on #python on Freenode. We take the XY problem very very seriously, and outright refuse to give Y answers when it's clear the user should've mentioned X, and we push the programmers who come to us for advice towards proper solutions for their actual problems.

On Stack Overflow, establishing and resolving X problems is hard, while giving a Y answer is a way to instantly receive rep. This is a problem! As a community, we need to think about how to fix this problem. Does anyone have any ideas?

  • 6
    Remind me never to visit #python. ##java is worse enough
    – TheLQ
    Commented Jul 9, 2010 at 5:11
  • 2
    #python is fine if you come with an open mind. If you come with a know-it-all attitude then you will get ground down bit by bit. But you will also come to really know it all. Commented Jul 9, 2010 at 5:14
  • 6
    Yes! I just answered an XY problem today and the OP got mad at me that I didn't like Y - stackoverflow.com/questions/3205004/…
    – Ether
    Commented Jul 9, 2010 at 5:18
  • 2
    It's a nice principle, but I've seen quite a few knowledgeable users on #python be told, "don't use Y," and then simply be ignored when they asked how they should approach the problem. For example, I was told to use Twisted to do asynchronous work in a PyGTK app. How? Nobody knows. I'm still using threads and hating it, but god forbid I ask for help with any aspect of my app on #python...
    – detly
    Commented Jul 9, 2010 at 5:59
  • 4
    It's actually an interesting instance of the Dunning-Kruger effect: the askers aren't knowledgeable enough to know to ask X, the knowledge required for that is the same as what would be required to answer Y. Commented Jul 9, 2010 at 6:07
  • 1
    can you cite some specific examples? It's hard to talk about these problems in the abstract. Commented Jul 9, 2010 at 6:24
  • @Jeff: for one: stackoverflow.com/questions/3209901/… the OP wanted to find the absolute path (Y) so he could load a resource (X), but the real answer was to use the ClassLoader -- which he didn't understand how to do. Commented Jul 9, 2010 at 6:31
  • @Mark - I'm no Java expert, but isn't that the answer he accepted?
    – detly
    Commented Jul 9, 2010 at 6:33
  • @detly: it is. unless I'm reading wrong, the discussion here is about asking for Y when Y = F(X) and the real question is X. In this instance the outcome was positive, I recognized the problem as X from symptoms of Y. Commented Jul 9, 2010 at 6:41
  • @Mark - right, I misunderstood your intent. Although I thought the discussion was about asking for Y and getting an answer for it instead of X.
    – detly
    Commented Jul 9, 2010 at 6:50
  • 1
    @Ether you were supposed to use your clairvoyant abilities to accurately measure the degree of experience of the poster, and thus to deduct whether it is a stripped down example, or a stupidly copy+pasted snippet.
    – Pekka
    Commented Jul 9, 2010 at 8:11
  • You know, I just realised that one of the seminal examples of this is RegEx match open tags except XHTML self-contained tags (except that again, the OP went with the suggestion to rethink their approach).
    – detly
    Commented Jul 9, 2010 at 8:45
  • 3
    There are plenty of regex-for-HTML questions that had the opposite result. stackoverflow.com/questions/299942/… stackoverflow.com/questions/29869/… stackoverflow.com/questions/356340/… stackoverflow.com/questions/445642/… stackoverflow.com/questions/317053/… and many more. I'm not sure if regex-HTML is an ideal example of the XY problem, though. Commented Jul 9, 2010 at 11:42
  • 1
    Y'know, I think that title edit removed half the point of the question. It wasn't just about the askers, but about the answerers.
    – detly
    Commented Jul 9, 2010 at 14:24
  • I'd posit that over 90% of questions tagged 'regex' are XY problems and for over 90% of these 'regex' is not the solution. Should we give out a regex anyway?
    – johnsyweb
    Commented Sep 27, 2011 at 9:20

8 Answers 8


If I am the asker and I'm asking how to do Y I want to know how to do Y. It's fine to suggest that I might do X in a different way, but I would not call that an answer to the question.

If you think I shouldn't be doing Y you're entitled to your opinion, but I didn't actually ask for your opinion on that - I asked how to do Y. Is it possible that I asked the wrong question? Sure! In that case I should learn from my mistake and make another post, asking the right question. But I consider it somewhat arrogant if someone just tells me "you should not be doing Y". It's possible that I'm right and they're wrong and Y really is the best way to do X, at least in my particular case. Perhaps I didn't explain all the details of why I'm doing Y. I don't feel that I need to, since I'm not asking whether I should do Y or not.

So, in summary: to suggest a different approach is fine, but to assume that you know more about the asker's problem than they do is arrogant.

  • 3
    This is just my opinion, but if you want to do Y and know it's inferior in general, then you should mention that. Otherwise, as an answerer I would rather err on the side of caution.
    – TNi
    Commented Jul 9, 2010 at 8:40
  • I agree with @Evgeny, it is arrogant to second guess the questioner and say "Don't do that" as your only answer; maybe the questioner has good reason but explaining why requires explaining too much context. If you answer "Here's how and oh-by-the-way, it's not a good idea and here's why", that's not arrogant because you've answered their question and gave them some helpful advice but to only say "Don't do that" means that you are presuming you know all valid use-cases and that it's not appropriate for any of them and there's not a human alive who can know all valid use-case for anything. Commented Oct 23, 2010 at 0:58
  • 3
    I can't disagree with your perspective more. Answers don't help people, solutions help people, and we should see it as our duty to provide optimal solutions to people's problems. (I certainly don't want to help people write software suboptimally, especially not for free!) This can certainly be taken to an arrogant level, but it doesn't have to be at all. If someone came on chemistry.stackexchange.com asking "What can I put on my wife so that the the police dogs can't find her corpse?", I wouldn't answer "Use lye," and I don't think that's because I'm arrogant. Commented Nov 3, 2010 at 13:24
  • 2
    I see your point about solutions, but it's not that black-and-white. A solution requires understanding the whole big picture. For a complex problem that's often not practical in a forum like SO. What is practical is getting the answer to a small, specific part of the problem. If the asker is a competent professional (and that is the primary audience of SO) then it's up to them to turn the answer into the solution. That's certainly the way I prefer to work. As for your chemistry example, it is not analogous to the XY problem.
    – EMP
    Commented Nov 3, 2010 at 22:23
  • I really think it is analogous to the XY problem. The situation needs to be dealt with, but the asker was way off in the wrong direction in how to deal with it and was asking a specific, concrete question relevant to taking the wrong path. Commented Nov 8, 2010 at 14:50

I never noticed this problem. In my experience, answers suggesting best-practices will get more votes.
In fact, I'd say the opposite is a problem: sometimes the OP willingly chose an inferior Y (sometimes they have a good reason, too), and they can't get a real answer, between all answers and comments telling them they shouldn't do it that way.

  • 1
    I think the problem is often people don't say why they are forced to choose "bad approach Y", they just state it as fact, or worse - not even mention that they have considered the obvious alternatives. If we know the reason why they think they must choose approach Y it can help find alternative approaches that are better and will still work given the constraints. Or if there are no alternatives then at least we can see that from the start instead of having to extract that information slowly out of the OP.
    – Mark Byers
    Commented Jul 10, 2010 at 1:27
  • 1
    @Mark: absolutely. I guess what it comes down to is people often don't know How to Ask a Question the Smart Way -- i.e. by giving some background context.
    – Ether
    Commented Jul 10, 2010 at 2:34
  • This hasn't been my observation at all. Direct, short, often-unhelpful answers very frequently gather upvotes and checkmarks; it's a lot easier to address problems at that level of thinking, so a lot of people don't put in the extra effort to consider the potential fragility, complication, unscalability, untestability, unmodularity, or nonidiomicity of direct answers about misguided solutions. I'm tempted to link some examples, but think I won't; I would like to be concrete, but don't want to create drama. Commented Nov 3, 2010 at 13:11

The same problem has been around since the Unix days. Eric Raymond's How To Ask Questions The Smart Way has a section on asking about goals, not about the step you are stuck on.

I know links to HTAQTSW are not helpful, but the advice on dealing with such questions is.

  • Handing out this link to users who ask incomplete questions can be frustrating, but hopefully people learn...
    – Ether
    Commented Jul 10, 2010 at 2:35

I think it's time to get actual discussion rolling, so I'll give this "ideas" thing my best shot.

These are all independent, and many are unrealistic. But, hell. These are numbered for convenience in the discussion, and not listed in any particular order.

  1. Create a new reason for closing a question: "Does not provide the X in XY". This allows voters to cleanly cut off really bad questions with really bad answers.
  2. Create a delay before answers can be provided. This is good for other reasons (e.g. it allows people to write more than a few lines and still be one of the first to answer), but in this particular case it allows breathing room for people to ask the question-asker about the "X" if necessary.
  3. Add the XY problem to the rules/FAQ, making it clear that X is important.
  4. Raise the prominence of comments on the original question. These are the most important comments anyway, and are generally the place where questions about X get placed. This would make any discussion about X more visible, and also possibly encourage more of it.
  5. Make comments to the question more important, letting them give rep. If users can get rep for asking about X, they will be more prone to do so.
  6. Provide a field when asking a question for explaining the X in XY. By providing a place to write it down, SO would offer tacit encouragement to explain it.
  7. Remove the terms "Question" and "Answer" from SO altogether. Replace with "Problem" and "Solution". The point of the XY problem is that Y is the question, and X is the actual problem, and a good solution for X may not be an answer to Y. See: all those questions where the "answer" to "What regex do I use" is "use an HTML parser", which obviously doesn't answer the question at all.
  8. Separate upvotes for "X" from upvotes for "Y" solutions. when upvoting/ranking questions. This is another visibility thing: by making the XY problem more visible, SO would encourage people to fix it. It would also be nice if X answers were weighted favorably.
  9. Get rid of bounties. These encourage pandering.
  10. Allow comments to the question to be selected as answers. This is incompatible with a few of the ideas above: the idea here is that comments become the means for answering X, and answers become the means of answering Y.

Summary: Encourage comments, raise awareness of the XY problem, discourage answers that are "only" answers and questions that don't label the actual problem.

  • 1
    +1 for the obvious thought you've put into this.
    – Ether
    Commented Jul 10, 2010 at 2:36

As I see it SO is designed so that a good answer does not have to be "green tick accepted" to (a) feature near the top of the list and (b) reward the answerer who did the right thing and tried to help solve the underlying problem. Compare rep for an accepted answer (+15) to that for an upvote (+10). If the "good" (solves X) answer gets even two more upvotes than an accepted "dumb" (solves Y) answer, then the person who posted it has been rewarded more.

So if #python members are concerned about this, why don't they come to SO specifically to look out for this sort of question? If they change someone's mind, great! If not, a genuinely good attempt will hopefully still gather upvotes and be prominently displayed.

Please note that I'm not specifically targeting #python-ers, just running with your example. This sentiment could apply to any other technology-specific group, like members of some officially sanctioned language forum.

To put it another way: if the problem is perceived as "too many solves-Y answers on SO," then the people charging that should come over and lend their "detecting-and-solving-X" expertise.


On example I see a lot is the low-level char string manipulation in C++, when the "X" answer is 'don't do that, use std::string'.

It's worth asking "have you considered std::string?" but the usual response is...

My tutor says we're not allowed to use that for this assignment

When I post a code snippet as part of a question, I intentionally strip the code to the bare bones necessary, because I don't want to burden answerers with wading through unnecessary detail: No error checking, short variable names (i/j/foo/bar), etc. It's frustrating when so-called "answers" are simply criticisms of this coding style.

So, I usually try and answer the question "as asked", but add alternative approaches as a "Have you considered X" comment.

  • Is there a place for your minimal code snippet to be posted here, and a fuller version posted somewhere else? That seems like it might be a useful convention.
    – DanBeale
    Commented Oct 3, 2011 at 21:43

I agree the problem exists, and I think people who pay extra attention to X, pointing the user towards it, are doing a great (and often unrewarded) job.

However - this is in no way directed at you, @Jerub, I don't know you and I'm not active in your tags - this is often decided by the tone used. Sometimes, X gets downvoted because, while being correct, the option is presented in such a rude and arrogant manner that everyone is pissed off.

A politely and nicely presented better alternative seldom fails to gain recognition in my experience.


There are two approaches to this problem:


Just ask them question using the comments, trying to push them into giving you the information you need to answer the right question (not necessarily the question they asked).

This is tricky because some comment sections quickly crumble into a bunch of chatter and noise.

JUST ANSWER THE RIGHT QUESTION, not necessarily the one they've asked

So long as you're polite you can point out the problems with their approach and suggest the right approach.

SOmetimes this is great because they didn't have the language or knowledge to ask the right question and they'll be glad that you saved them a bunch of time by steering them some other way.

Sometimes they'll be grumpy that you presumed to know more than them about their situation. So long as the answerer is polite they can ignore any grumpiness. And if the right answer isn't helpful to that particular asker it may well help someone in future.

SE is pretty big now, and some SE.sites will have people asking questions about situations that they're forced into by some idiot PHB (or similar situation). Those askers need to point that out. They know they're being told to do something stupid, they're going to be frustrated with people telling them that they're doing something stupid. I guess part of "be polite" is "realise that there might be office politics forcing the asker to do something sub-optimal".

Another thing

The XY problem introduces complications around identifying duplicates. "I want to do X" followed by a bunch of links to people saying how to do Y is not fun unless there's a nice post with explanation about why Y is better.

Wow, tl;dr.

You must log in to answer this question.

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