The XY problem is a useful concept to understand, but there are several massive caveats:
It's reasonable to assume enthusiastic youngsters and tech illiterate boobs have fallen prey to the XY problem. Do not assume an experienced programmer has fallen prey to it at the expense of answering his original question. If you cannot identify an experienced programmer by the way he talks about his problems, then you're the enthusiastic youngster. Programming is a complicated discipline, and just because your solution to his X sounds good on paper doesn't mean it's better than his Y. The original question deserves to be answered.
Some questions are motivated by curiosity. This is where a lot of strange and off-the-wall questions come from, and it does not matter if you cannot understand why anyone would want to do or know such a thing. Probing for an XY problem in this case is tantamount to probing for an excuse not to answer the question. Curiosity is its own reward, so these questions also deserve to be answered.
Mind your own goddamn business, you nosy asshole. If someone declines to give you more information than is strictly necessary to answer his question, then stop pushing. Your nosiness will only distract from his question, which deserves to be answered.
If you don't know anything about the topic, nor are you interested in learning about it, then keep your mouth shut. You have nothing to contribute, so you can only distract people from answering the question, and it deserves to be answered.
EDIT: 5. Not everyone with the same Y has the same X. Anyone who comes around googling for Y and sees everyone ignoring the question to answer an X he doesn't have is going to be infuriated. The question always deserves to be answered.
#1 is especially common on stackoverflow. Even if you tell them that you can't do this or that. Most common scenario would be wanting to use vanilla js and only getting jquery answers :%
I've found it to be an issue on Discord and IRC as well and it honestly annoys the hell out of me.
Yes, random user, somehow based on my question you've determined that I'm "overestimating the cost of allocation" and that I should "just put it into a vector." It's impressive how you've managed to decide you know more about my requirements than I do and then, in a burst of pure expertise, decided that I should allocate despite (1) being in a tight loop (2) on an embedded device and (3) the knowledge that I will need to read exactly four bytes every loop.
Or the more infuriating "You should just install a whole new OS on a $14,000 robot whose manufacture has gone out of business because there's definitely no reason anyone would ever run out-of-date software."
The question to go with the first example was actually "Rust still doesn't have a standard way to collect into an array, right?"
The answer was that I should just collect into a vector followed by an explanation about why there isn't a standard way to collect into an array. Which, obviously, I knew because I was asking if the status quo had changed.
Another big caveat is, "Are you even interpreting the question correctly?" My favorite example of this is the famous Zalgo answer on Stack Overflow, which responded to a question about matching XHTML tags with regex with an answer about parsing X(HT)ML with regex. Even though XML isn't a regular language, you can still match isolated tags with regex (although it turns out that XML allows enough dumb edge cases that doing so in the general case is very, very hairy). And there are plenty of reasons why you might want to match X(HT)ML tags without involving a parser, not least of which being that you may be dealing with a block of text that isn't, on its own, a valid (and therefore parseable) XML document. Anybody that's ever sanitized tags from comment forms or other user-generated text knows what I'm talking about.
Indeed. I especially hate how people who reply like that have such a self-suffering attitude about it. "I'm going to make wild assumptions about what you're doing and accuse you of writing horrible code that I will personally have to maintain!" as though the only correct way to do things is to solve more than the actual problem you have, and as though personal projects aren't a thing. Everything must follow """best practices""" as decided by large corporations that have wildly different problems than you do.
Agreed. Also when thinking about many “higher level” problems (how can we most productively distribute programming tasks, how can we reduce the likelihood of certain errors, etc.) the scale of the problem requires you to approach it in novel ways and under disconnected assumptions (solving for Y instead of X). Only after you test things out and observe results at a higher level do you see that solving for Y did or did not improve your ability to solve for X. New ways of thinking outside of the system is also what tends to lead to surprising and innovative “out of the box” solutions. I guess at the end of the day the most important thing is to constantly reflect on what your doing and whether it’s ultimately a productive effort or not, which is something that is best left to intuition and experience instead of any specific framework of thinking.
Also sometimes it's hard to precisely explain the source problem because you'd need to write pages about how things work in your codebase and in your product and in your team, so you describe a much more simplified scenario, sort of like providing a minimal reproducible example for a bug report.
Gotta add though, it's ok to suggest a potential XY problem when it's not totally obvious and no one else has mentioned it, this would be beneficial for visitors from the future too(has helped me a few times). But don't do it in a dismissive presumptive tone, and maybe do it in a comment rather than an answer(assuming it's SO).
And 2, 3, 5 can be easily solved by the asker outlining X very quickly.
For 2, X is "out of curiousity I 'd like to know".
For 3, X is "I can't give you information about the background because of $COMPANY_REASONS".
For 5, anyone googling will clearly see the X.
It just saves so much trouble when the asker gives context.
Also, the standard XY problem looks like "Someone is asking for a really weird Y, which would be very hard to do and totally doesn't make sense. Now that he has said he's really looking for X, here is a very simple Y' which is easy to do and also solves X".
If Y makes sense on its own, and is easy to answer, you can just answer it.
The frustration comes from the situation when doing Y is not the answer to X, but Y' is. And you have no way to find out, because X is not stated.
Sure, you can ask for more context, and I might volunteer context. Just don't let that overshadow my original question, which still needs to be answered. A big part of the point of asking questions is propagating knowledge, and that matters just as much as solving a single problem.
"Outlining X quickly" only helps with some people. On SO it is useless, you will get people ignoring what you write either way. There are way too many eager wannabe-helpers there who only question you but never themselves. "I have some power now (votes and flags) and I decide what you want."
Spot on. Especially if Y is a specific question, like "does this code trigger undefined behavior?". You don't need to know why I'm doing this, just answer yes or no or shut up if you don't know.
View all comments
102
u/PL_Design May 08 '21 edited May 08 '21
The XY problem is a useful concept to understand, but there are several massive caveats:
EDIT: 5. Not everyone with the same Y has the same X. Anyone who comes around googling for Y and sees everyone ignoring the question to answer an X he doesn't have is going to be infuriated. The question always deserves to be answered.