What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 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
97  
XY "problem" ... are you suggesting men are trouble? –  Jeroen Sep 27 '12 at 8:46
2  
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
3  
@Jeroen, "XY "problem" ... are you suggesting men are trouble?" Hmm... so this means my girlfriend's idea that solving Y in me will fix everything, when really it's an X problem in her? I can't wait to tell her! :-) –  Greg Nov 7 '13 at 19:08
1  
I've seen YX problems too. –  Ramchandra Apte Dec 6 '13 at 15:34
1  
this problem could really use a rename. using something sourcing from perl is probably not the most readable approach on the planet anyway. And you will usually face it in the form of "what are you trying to achieve?" , why not just call it that? –  naxa Mar 6 at 16:19
2  
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 at 23:24
    
@Handoko not enough attention? It's a FAQ, what exactly do you expect to achieve by setting a bounty?! –  Shadow Wizard Jun 8 at 11:53
    
Huh? I didn't even know I've put a bounty here lol. –  Handoko Jun 8 at 15:41
    
How do I unbouty it? –  Handoko Jun 8 at 15:42
    
@Handoko wow, that's a first. It requires lots of clicks to set a bounty. You can't unbounty, your only chance is flagging this question, choosing "Other" and pledge your case (diamond users who happen to be Stack Exchange employees here can cancel an active bounty). But good chance the flag will be declined, bounties are not a game. –  Shadow Wizard Jun 8 at 19:39
    
Ah I see. Well. I don't really mind the reputation I'll lose for this site. I still don't know why it comes that I've put a bounty on here. But who cares –  Handoko Jun 8 at 23:10
    
Now we have that +50 icon on here xD –  Handoko Jun 8 at 23:13
add comment

3 Answers

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
49  
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
165  
The easiest way to get to the real problem is usually asking Why five times. –  Gordon Oct 21 '12 at 17:25
3  
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
18  
Why Y - that's the question to ask –  user93353 Apr 23 '13 at 14:49
4  
Your example is perfect. –  paraxor Apr 29 '13 at 20:15
17  
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
21  
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
18  
@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
10  
@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
6  
@Gordon Why 93 up votes? Why? Why? Why? Why? –  Kris Oct 1 '13 at 6:42
2  
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
4  
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 at 17:07
1  
An example of precisely this from earlier today. –  geotheory Feb 20 at 19:42
1  
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 at 13:48
1  
Just ran into a great example of this today. –  Jason C Apr 19 at 18:49
show 1 more comment

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.

Source

share|improve this answer
3  
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 at 6:16
4  
@Emrakul I think this answer does a better job of explaining the problem. –  cimmanon Jun 13 at 12:07
add comment

This "asking a question at the wrong level for the sought solution" is intrinsic to what problem-solving processes are about. Learning is kind of about not knowing, and then knowing more--fumbling a bit through new methods and finding stuff out. Knowing the solution at the level of the solution does not require asking questions.

It only becomes an issue when someone's lack of a dependent piece of knowledge is pointed out to them, and they don't respond by investigating those concepts but persist with "give me teh codez". So I'll say this X Y "problem" is not a measurable characteristic of the question being asked--it is a problem with the way that feedback is processed when someone is advised on their situation.

Case in point...I found this X Y meta post linked in response to this question from a brand new user:

Accessing adjacent elements of a map in c++

As of now it has received 4 close votes closed (all right fine, reopened, I'll shut up now). It did have an edit but the edit was formatting; there was nothing essentially changed.

The negativity toward this question is totally unwarranted. It doesn't really need to be reopened because I answered it already, but what a rotten way to treat a new user asking a fine question. The floating point keys are monotonically increasing, the values are not--the asker knows what the ordering is. It contains a clear question ending in a question mark:

Can I directly access the adjacent values by just knowing about a single mapping (m[2.65]=54)?

I'm not a mind reader (or if I am, that is beside the point). But I think the negativity is because this person sought an answer besides find, even in the original question. I don't think it's unreasonable to ask if there's anything like m[2.65, -1] and being reluctant toward "gibberish" starting with std::map<float, int>::iterator iter = m.find(2.65);, involving testing against end(m) and handling that, then *(iter--) and getting "worse" from there.

So that's not the X Y problem. Could it become the X Y problem? Sure, if there's a process of resisting good advice. But the X Y problem is not "we know C++ and you aren't worthy yet because you're looking for a way to twist bracket notation to get adjacent map elements".

This response was offered:

It is a form of XY problem, because the correct solution (which you also gave in your answer) is rejected as a possibility in the question

So people are to punish: "I have located some information that suggests an answer--but it is not shaped how I expect, or the documentation pages are over my head a bit--is there a more natural way?"

...but only if they were right. Had they been barking up the wrong tree and there was a better answer, it's not penalized--because the wise questioner knew enough to know something was up, and asked before proceeding.

?

There are some things that are on the unconstructive list...like linking to "let me google that for you" as an answer. Seeing 1-rep users get linked to this, downvoted and closed, is the same thing to me. Constructive feedback is stuff like teaching people how to ask with the short self-contained compilable example. This X Y tautology just looks like fluff promoted by bullies who don't know how to (or care to) teach.

share|improve this answer
    
This rant about a question doesn't belong here at all. –  Karoly Horvath yesterday
1  
@KarolyHorvath You'd be the one drawing the relationship, with a comment I find to be unconstructive treatment of a fully answerable question...combined with joining in on the close vote. "You have the X Y problem, closevote" is not an answer to that question, and I challenge the idea that this meme has merit and should grow and be thrown at 1 rep users while you drop kick them out the door. –  HostileFork yesterday
    
Basically you're assuming people closevoted because it was an X Y problem. They probably weren't. At least I know I weren't.. and BTW I find your whole poblem purely academic, as the user hasn't responded to a single question. You cannot teach without a feedback loop. –  Karoly Horvath yesterday
1  
@KarolyHorvath You cannot teach when you pound brand new users who have perfectly fine questions with all negative comments, downvotes, and close their questions in less than an hour. Because it's a rotten experience and why would they come back? It reminds me of the joke about the gorilla at the bar who orders a banana shake and hands him a $100 bill, and the bartender thinks "what does a gorilla know about money" and gives him $1 change. Gorilla drinks, and eventually the bartender says "don't see many gorillas in here..." and gorilla says "at $99 for a banana shake, I'm not surprised." –  HostileFork 18 hours ago
    
I've never had problems with users who show the will to listen and learn. For the rest, I don't really care. Hey, it's a competitive market, if they find a better place, they should leave. Or stay, and get used to it. I also have downvoted questions and received stupid comments, it's not the end of the world..... And I would kindly like to remind you again, that this is all ridiculously off-topic here. –  Karoly Horvath 18 hours ago
    
@KarolyHorvath Spelling "find" wrong when asking if one can achieve adjacency without using it is not listening? (From a new user who doesn't necessarily even realize if they can edit their comments). If you point me to where this discussion is on topic, I'll relocate. But I put it here to get it off the question, and I'm up to 4 reopen votes so good. But yes--it's a broader question; with lots of meta posts about elitism--and I just wish w/your rep score and knowledge you (and others) were more in line with my answer. You're shooting first, asking questions later, and citing tautologies. –  HostileFork 17 hours ago
    
Looks like you have an XY problem. And I haven't written this for the sake of a recursive pun. –  Karoly Horvath 16 hours ago
    
@KarolyHorvath You're not doing it for much sake without defining X and Y. (I could riff where Y is talking to you and reverse-engineer X from that.) The question is reopened, yet given that won't change how you see this exchange, I'll finish with a "Moment of Zen" (as per The Daily Show). Here's a small scrap from when I was learning to program: greatest games. I want all of us to think about the opportunities, and the costs, of how our small fake Internet points may be applied to the experience of future programmers. –  HostileFork 12 hours ago
add comment

You must log in to answer this question.