What is the XY problem?
When asking questions, how do I recognize when I'm falling into it? How do I avoid it?
What is the XY problem?
When asking questions, how do I recognize when I'm falling into it? How do I avoid 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.
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.
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.
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 possibleQ: This code actually comes from HTML
Q: But I don't know how to parse Javascript with HTMLParser or whatever it's calledD: 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.
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
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.
See also "XyProblem" on GreyCat's wiki.
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.
"Why Your First Idea Can Blind You to a Better One" explains an example from chess where a person wins 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:
For example, you are trying to solve an issue: how to compost your household organic waste. When considering how to solve the problem, you might think of several potential solutions: compost with a municipal government program, do backyard composting, or compost with worms. Let's say that a municipal program is not available and you pick to do backyard composting. You soon end up with a blocker: there are rats getting into your compost, and they're invading your kitchen too! You go onto a Q&A forum and ask, "How do I get rid of the rats in my kitchen?"
You have just fallen into the XY problem! You might get useful answers on how to get rid of pests, but no-one will be able to solve your problem because they're not addressing the source of the problem and the rats keep coming back.
It might be better for you to ask the Q&A forum about how to solve the original issue you were trying to solve. e.g. ask, "How should I compost my household waste?" Then you might learn that you shouldn't compost meat or dairy products in a backyard compost bin because they can attract pests.
Einstellung effect
description is based upon an obvious mistake. Luchin was experimenting how people would deduce the problem from his incomplete and ambiguous description (was he asking for optimization for latency or optimization for throughput?). However he made himself delusioning that he allegedly still was experimenting on "how people come to solutions". That is a referential thing perhaps. Luchin was so focused on his interest, that he failed to notice when he diverted to a very different problem.
Commented
May 16, 2018 at 9:52
Avoiding the XY problem
I argue that you can't avoid it. Not without simply throwing your program requirements at SO and asking them to do your design for you (not recommended).
I argue this because the design process for all software is based on a starting set of requirements "A". From there you say "I can achieve A if I do B and C". From there you say "I can achieve B if I do D and E and I can achieve C if I do F and G". And that continues to the point we say that "I can achieve X if I do Y". We usually do this so fast we don't even think about the process.
So the major problem with the XY problem is that Y is not possible, but you don't know how much of your design to unwind to get back to the X which is possible. You usually don't even know that Y is impossible without actually asking. You don't know what you don't know. Therefore it is unavoidable
Asking Questions where you risk falling into XY
The best thing you can do about the XY problem is to guard against it when asking questions. Still ask the same question but give as much pertinent information as possible:
This will help people identify that its XY and help you much more quickly.
IMPORTANT: Giving Answers to XY problems
In my opinion the biggest problem with XY questions is the (frequently) unhelpful answers they provoke. We will never stop people asking these questions so the best thing is to understand how we can answer them quickly and effectively.
Ironically a lot of these bad answers and responses are given by those wanting to be the most helpful and can be given by some of the most reputable people on the forum / SO.
I've discovered a method of answering these questions which appears to help get round the psychology associated with XY problems and lead the OP of a question to a working solution. The method takes a little longer to answer in the first instance but closes the Q/A loop much more quickly.
I suggest that you answer the question in three parts and give them in the following order.
Answer the OP's question. Even though the OP probably needs something else, never neglect to answer the question they have actually asked first and not the question you think they want answered. In some cases that answer may be "Y is not possible". Too often I see responses (comments) asking "why do you need that?". This gives the OP nothing. If you say "That's going to be really hard. Explain why you need it we may be able to help" then in a lot of cases an OP will simply take the "Y is really hard" and go back to the drawing board... That's fine because you've answered their question and they may well come back with question X themselves.
Discuss the OP's attempted solution. This bit's tricky and takes some thought. But I can't stress how important it is. If the OP has asked for Y and you think they want X then after answering their question (1) carry on to talking about Y (NOT X). What is Y supposed to be used for? How is it not applicable to X? The crucial thing is to carry on talking about the question but move from answering it to providing helpful information. Because after all that's what you think the OP needs. Helpful information and not the answer to their question.
Solve X This is what you've been itching to do and is the whole point of your response after all. You've met the OP on their terms and answered their question. You've helped them to understand the failings of their question and why solving Y is not the thing to do... so now you're completely justified in explaining a solution to X.
Most people are here to learn so parts 1 and 2 of this answer are as important as part 3. But too often part 3 is given on it's own and it is extremely frustrating and patronising to the OP not to mention a lot of OPs will not accept the answer.
Giving this answer also avoids embarrassment when you think the OP has an XY problem when in fact they don't. All you've done is give a little extra information. Simply giving part 3 risks appearing to have not read the question.
Incidentally. Read the question again and read this answer... notice the three parts?
The Missing square puzzle problem is a good illustration. It illustrates a simple and universal problem/question/solution process, where "some illusion" causes complications.
There are a self-evident problem — the 1×1 hole in that arises on the second figure —, but the solution is evident only after we know (like an Egg of Columbus)... All people, experts and non-experts, agree that there is a problem.
normal user: thinks that
"there are two equivalent figures, the 'total triangles' in a perfect 13×5 grid...",
following with the question:
Y
: "Why does the second equivalent triangle have a hole in it?".expert user: think something like
"oops, they are alike (close in shape), but not perfectly equivalent figures",
following with the question:
X
: "How to show that they are not perfect equivalents?".The clever geometry-expert thinks in terms of close in shape geometries.
The normal user thinks, mistakenly, in terms of exact congruence. So, the use of wrong hypothesis, produce ill Y
questions.
You want to solve the real question-X
, and you think in terms of an Y
-context, and try to use question-Y
. Instead of asking about context X
, you ask about context Y
.
(as @Gnome noticed above, but using other words)
So, "XY Problem" is only another (more specialized) term to say "Use of wrong working hypothesis". See examples at this question/answer.
(separated from my other answer because this one has more opinion than explanation)
If you agree that the "XY Problem" is only another (more specialized) term for "Use of wrong working hypothesis", as illustrated and explained here, and similar to the "Einstellung effect" explained here by @Jonathan Benn…
We can think in terms of some main situations:
Rush situation: the wrong hypothesis is only a language or over-simplification side-effect, that can be corrected by the user with a little more attention, and investing more time editing the question.
Normal situation: as in the illustrated Missing Square puzzle, you do not know that your hypothesis is wrong. This is the main situation to discuss here (!).
So let's put focus on the normal situation.
The Stack Exchange question is to show a problem. If my question helps to show that the real problem is my wrong hypothesis, it is OK! It is a first step, and perhaps I will not need any other questions after obtaining the correct hypothesis (and trying to solve by myself).
Example. See "XPath for xml:lang? Testing attribute self axis fails"; the real problem is that @attribute::self
does not exist, so it was a wrong hypothesis on the title of the question.
help/mcve
solution has limitationsStack Overflow's help/mcve
rationale: "How to create a Minimal, Complete, and Verifiable Example", can be used to avoid the XY problem.
But the cost of edit (time and attention expensive), and the perception that it is a kind of pollution in your text (a "bad marketing" for the question), are downsides.
It's correct also to simplify the problem and explain with more focus on the point.
Train users of Stack Overflow to check if the simplification makes sense. Algorithm for a good question:
Try to create an MCVE.
If an MCVE is not practical, try at least to simplify.
2.1. Test, check for inconsistencies, simulate the reader… and review. Does your simplification produce something strange, change the context? Review to avoid errors.
Listen to the comments about your question, and try to clarify, try to work editing the question if necessary: if there are people commenting, it is a notice that you can invest more time in your question.
The wrong hypothesis is not self-evident, but when we simplify, we amplify the wrong effects, and it becomes more evident.
PS: On the other hand, when we explain and show all the details, all the context, and check the real point, the assembly of the problem (like when using mcve
), the inconsistencies also show with more evidence.
Negotiating a union contract...
The XY problem is relevant to the difference between "interest" based bargaining (X) and "position" based bargaining (Y).
X = the employee's overall take-home pay has been stagnant for the last several years, while their cost of living continually increases; the employee needs more take-home pay.
Y = picking "you will not raise parking fees" as a hill to die on / the only "solution" to X that the employee is willing to accept.
Aiming for Y (taking a position) is aiming for a very specific and limited solution to the problem (X). It cuts the employee off from from the universe of solutions to the problem (X) by insisting that it only be solved in one very specific and limited way. If that way (Y) is, for whatever reason, objectionable to the employer, then there will be a stalemate -- a period of time where there is no solution to X, where a solution has to be acceptable to both sides.
If the employee can aim for X instead of Y, then the universe of solutions remains open / unrestricted, and the employer can be recruited to help find possible solutions to X. (Maybe it will turn out to be OK with the employee to raise parking rates, in exchange for a cost of living raise...)
This interest/position paradigm seems relevant to asking questions on SO, when OP asks for help making their position work. Sometimes you can cut to X by simply asking: "Why are you trying to do this?"; But I wonder if sometimes, aiming for Y isn't just as valuable. How many of us have ever tried to do something, just to see if we could? Anyone here running their own DNS server with some specific type of software for that very reason? :-) Might not be your best solution to X, but it's still interesting...
X
instead of solvingY