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

What is the XY problem?

When asking questions, how do I recognize when I'm falling into it? How do I avoid it?

Return to FAQ index

share|improve this question
See a PerlMonks post on the same subject. –  ikegami Jul 31 '13 at 19:34
sad example of the XY problem: stackoverflow.com/questions/2691018/… disclaimer I'm biased there, being the one claiming spotting X instead of solving Y –  Tobias Kienzler Aug 16 '13 at 9:12
I have heard this problem called “premature closure” in a logic course. However, searching the internet for this phrase shows it more commonly means suturing a surgical incision too soon. –  Dour High Arch Mar 23 '14 at 23:24
Folks who know the answer to a problem ask X, like teachers on a test. Mere mortals tend to ask Y. The XY problem is a dance between post-er and post-ee. –  chux Nov 4 '14 at 16:04

3 Answers 3

What is it?

The XY problem is asking about your attempted solution rather than your actual problem.

That is, you are trying to solve problem X, and you think solution Y would work, but instead of asking about X when you run into trouble, you ask about Y.

The Problem

This can lead to frustration by people who are trying to help you solve the problem because by the time you ask about it, the solution that you need help with might not have any obvious connections to the problem that you are trying to solve.

How to Avoid

To avoid falling into this trap, always include information about a broader picture along with any attempted solution. If someone asks for more information, or especially a more specific question, do provide details. If there are other solutions which you believe will be suggested and which you've already ruled out, then don't try to avoid going over them again – instead state why you've ruled them out, as this gives more information about your requirements and helps others provide better answers.

An Example

A recent IRC conversation for illustration:

<Q> Is there a function to return a string between two delimiters?

<B> i don't understand what you mean, but i doubt there's already a function

<C> split and slice

<D> partition too

<Q> I tried partition
<Q> I was trying to use built-ins to get the number between something like this in a string "attribute1: 50.223, attribute2: 442.1"

<D> why not just parse the string?

<Q> I thought there may have been some built in parsing stuff

<D> pairs = [x.strip() for x in s.split(",")]; attribs = {k: v for x in pairs for k, v in x.split(": ")}
<D> there's a few libraries, but simplistic formats are easy enough -- if you don't care about error handling
<D> changing the source to use a well known format, e.g. json or yaml, is preferred when possible

<Q> This code actually comes from HTML
<Q> but I don't know how to parse Javascript with HTMLParser or whatever it's called

<D> is it merely embedded in html, or some mangled version of html?

<Q> It's embedded in the HTML

<D> if it's javascript (and that is, except for missing outer braces), json can probably parse it

<Q> thanks

<D> I didn't say it explicitly: json only parses data structures, not js code

<Q> That's all I need parsed is a data structure

The problem is really about how to parse JavaScript data structures, not find "a string between two delimiters", yet it takes quite a bit of time and intuition to get to the real issue.

This is easier to do in a fully interactive chat (regardless of what mode), but on a SE site, where you polish a post a bit, post it, and then have 5-30 mins, or longer, before feedback, it really helps to head in the right direction from the start.

share|improve this answer
IMO XY problems are sometimes useful because the answers could help the questioner understand why their solution wouldn't work, and better understand the original problem in the process. –  Thomas Jul 17 '12 at 16:26
The easiest way to get to the real problem is usually asking Why five times. –  Gordon Oct 21 '12 at 17:25
Although, if you start off with Y instead of X, you may have to ask why 10 times (or more, apply the 5 whys to every level?). :-) –  Brian Knoblauch Nov 30 '12 at 15:10
Why Y - that's the question to ask –  user93353 Apr 23 '13 at 14:49
Your example is perfect. –  Evan Teitelman Apr 29 '13 at 20:15
To be fair, many times questioners ask about X, and the response is "that's too much, break it down to a small example" and so the poster isolates their attempted solution Y and everybody loses sight of the original problem. –  Paul McGuire Jun 23 '13 at 23:48
Sometmes you are stuck with Y. In my first job I had to modify a webshop. The codebase was a rotten mixof html PHP and js. There were 2 ways to fix problems: Redo the whole thing (declined by boss) add more tape. SO did not really help me there. "How to y?" "Why would you do that?" "Because I have to" "What is Y / Do not do this/ why are are you using {antipattern}?" "Because I have to" –  Oliver A. Jul 9 '13 at 8:46
@OliverA. Then part of the question becomes an explanation of why you need to do Y. "I need to do Y because legacy/boss/old framework" then the question becomes easier to answer, and more valuable to all. –  Lego Stormtroopr Sep 4 '13 at 5:59
@LegoStormtroopr Except many people don't understand that. They don't understand that sometimes you don't have the luxury of choosing the right approach and just have to band-aid existing code, and the question is closed as too narrow or something... –  Thomas Sep 4 '13 at 23:19
@Gordon Why 93 up votes? Why? Why? Why? Why? –  Kris Oct 1 '13 at 6:42
Oliver A. is totally right. One cannot expect to have an perfectly isolated question, because there is a lot of conditioned situations. Ussualy when you dominate the topic, the answerer raises immediately and got the solution. Sometimes, the problem is in X format. Sometimes, in Y format (the inverse approach). Both, if well formulated, are appropiately made to offer a solution. Obviously is it totally easy for the answerer to have the problem formulated in X format, but, as obviously you also can figure, not always a questioner will find an ussualy answer from the X format. Good topic though. –  hypfco Oct 14 '13 at 21:50
I made solid attempts to boil all of my questions down to as much of a "Y" as possible. I have no interest in spelling out the entire scope of my issue (especially when working on closed-source proprietary software at my job), and I feel like (excluding dealing with those who insist on traversing up the chain with "why? why? why?") I can get an answer faster by encapsulating my questions off from all context. –  n00neimp0rtant Feb 14 '14 at 17:07
It depends on the asker's overall knowledge of the problem space. I agree with n00n, for those more experienced with the alternatives, they may have already ruled out all the possible X's, and now X is a constant, and they just want to solve for Y. It detracts from the question to have to go over all the possible X's that you've already ruled out, and delve into office politics or existing system architecture. Someone less experienced might benefit from having other's review alternative X's and suggest they reconsider that precondition. –  AaronLS Mar 20 '14 at 13:48
Summary (Part 2)... Me Programming questions belong on Stack Overflow and there's probably other ways you should be doing this instead of psexec/runas/etc. Why run the program as a service or as SYSTEM - can't you just run a background process as the user and minimize to tray or something? OP I want to be able to open files on network shares from across our intranet. Me Why not just use the file shares? OP I want to link to them from a web page. Me Here's 4 different Stack Overflow questions and a Google search for different ways of handling this. –  Iszi Jul 30 '14 at 19:55
(cont) So I wonder if there is any way to change the home directory for one thread. Other: Oh, I see. Well, you can't do that in Java. Me: Why couldn't you tell me that earlier? -- In that case, I asked question X and I was answered question Y (how to use files in Java). –  Florian F Oct 27 '14 at 22:35

The X-Y Problem, as it is sometimes called, is a mental block which leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. It often goes something like this

  • User wants to do X.
  • User doesn't know how to do X, but thinks they can fumble their way to a solution if they can just manage to do Y.
  • User doesn't know how to do Y either.
  • User asks for help with Y.
  • Others try to help user with Y, but are confused because Y seems like a strange problem to want to solve.
  • After much interaction and wasted time, it finally becomes clear that the user really wants help with X, and that Y wasn't even a suitable solution for X.

The problem occurs when people get their train of thought stuck on one approach and become unable to take a step back. Remaining open to having a new look at the bigger picture, these people might find their way back to X and continue searching for alternative solutions.


share|improve this answer
In what way(s) does this answer expand on the one above? As it is also community wiki, is it possible for you t edit any new content into it? –  Emrakul Jun 6 '14 at 6:16
@Emrakul I think this answer does a better job of explaining the problem. –  cimmanon Jun 13 '14 at 12:07
I also think this answer is a needed addition to the explanation. I read the above, tried to think about my current problem (whether it is an X or Y question), and when I read on to this comment, I got the "aha" moment of understanding that if I would have posted my question, I would have inquired about the Y not the X. The reiteration of my situation could be a mental block focused on how I am solving the problem rather than clearly stating the problem I want to solve is very helpful. –  user2421308 Feb 4 at 20:17

I'm adding an extra answer as a complement to the excellent answers already present.

An XY problem seems to be a subset of the Einstellung effect, where a problem-solver gets stuck on a particular solution and is unable to backtrack mentally to see potentially superior solutions. This psychological phenomenon affects everyone, novices and experts alike.

An example from Chess would be a person winning with a 5-move smothered mate in one game. The next game, the same player fails to see a faster 3-move mate because they are stuck on the idea of a 5-move mate.

Specific to Q&A, the perniciousness of an XY problem comes from the fact that it is frustrating for everyone involved:

  1. The person asking the question asks the wrong question (which is related to their attempted solution rather than the original problem), and then finds it difficult to clarify the question because they are stuck on their own solution. The proposed answers are unsatisfactory because they don't address how to implement the author's solution.
  2. People answering the question find it frustrating because the proposed solution doesn't make sense to them since they are approaching the problem from a fresh angle and are (presumably) not being affected by the Einstellung effect, and they find it difficult to get the original poster to clarify their question.
share|improve this answer

You must log in to answer this question.