28

This answer on Stack Exchange Meta would be a good basis for a help center article. It still needs a bit of work; namely I think the example is too long.

Questions which are XY problems frequently appear on Stack Overflow, and it would be good to have an article which addresses these.

This feature request is motivated by Add "magic link" for XY Problems. The responses are mostly:

If we're going to have an [xy] link, then there should be a help center article for it.

Well, let's make one.

13
  • 7
    I wholeheartedly agree, but I've always found that the top-voted XY problem answer is too verbose and doesn't capture the nature of the XY problem as well as the second-highest voted answer.
    – ggorlen
    Commented Sep 19, 2023 at 12:36
  • XY problem are maybe a little specific to have a dedicated topic on in the help center, it is more that the topic of the article should be to focus the question on a problem rather than (only) a solution. The explanation of an XY problem most definitely should have a prominent place in such an article but it shouldn't be the focus.
    – Gimby
    Commented Sep 19, 2023 at 13:09
  • 3
    More resources: xyproblem.info, en.wikipedia.org/wiki/XY_problem
    – VLAZ
    Commented Sep 19, 2023 at 13:24
  • Yeah, that Example in that Answer from the 'MSE' Thread is way too long, ... and not very clear... There are probably many-many and much better/shorter Examples in the [regex] Tag...
    – chivracq
    Commented Sep 19, 2023 at 17:19
  • In my opinion, it would be interesting to add the XY option in flagging, because if there is an XY problem, it implies that there is a low-quality question. Commented Sep 19, 2023 at 19:01
  • 3
    @DiegoBorba how exactly are people who are not OP to guess what is or isn't an XY problem? Sometimes we might be right. Other times, not. The only real way to know is if you're OP and you can accurately describe the problem. The rest is guesswork. Sometimes it's somewhat educated but still guesswork. Even then, I have had the experience more than once that the question asker would definitively say that their problem isn't XY, I'd answer the Y and yet it would turn out they actually wanted X. Which they claimed wasn't the case.
    – VLAZ
    Commented Sep 19, 2023 at 19:05
  • It would also be great if someone can come up with a better name or analogy for it, because "X" and "Y" are just generic variable names... "Troubleshooting the wrong solution" or some such would be more self-explanatory.
    – Lundin
    Commented Sep 20, 2023 at 14:11
  • @VLAZ It's often quite easy to tell even without domain expertise. "How to best hammer the screws down in my new wardrobe?" I doesn't take guessing to tell that the actual problem is something like "How to assemble my new wardrobe correctly".
    – Lundin
    Commented Sep 20, 2023 at 14:19
  • @Lundin and some times it's company regulations that only screws are used. Or something. To not belabour the metaphore - a seemingly Y solution might be sought but it's the only viable solution due to circumstances outside the asker's control. Some times it's not even a problem being asked about but it's a question about how things would work given some constraints. In order to understand things better. Which again is a "suboptimal route" but there is no X to try and find.
    – VLAZ
    Commented Sep 20, 2023 at 15:08
  • 1
    @Lundin an example of constraint-driven Y I see fairly often is a user searching for a regex that does something more easily done with string manipulation. Yet they work with some legacy system that only has regex as configurable rules. Therefore trying to answer the X of something like "how do I check if a string of any length has exactly three digits in it" using string manipulation does not address the real problem. Which is "I can only use regex to do this". (and yes, that's probably a duplicate)
    – VLAZ
    Commented Sep 20, 2023 at 15:11
  • @VLAZ, Hum, funny, I also mentioned [regex] in some earlier Comment, but meant as the exact opposite of your Example, from my experience in the small Tag I answer, where Askers often ask for a 'regex' Solution, while using 'regex' is nearly never the best Solution (in that Tag/ProgLang)... But in your Example, the Asker should have explicitly mentioned that constraint about their Legacy System... An [xy] problem always comes from the Asker not providing enough info for Answerers to have "the full picture" about the (whole) Scenario/Requirements and find the best Implementation.
    – chivracq
    Commented Sep 20, 2023 at 22:25
  • @VLAZ If the poster has artificial requirements forcing them to do things in a strange way, they need to tell that as part of the question. Otherwise we need to prompt for clarification and not answer until that clarification is given. Also note that "too localized" questions like "the company is forcing me to hammer screws - hot to do it?" are almost always bad questions with no interest to future readers. Same with deliberate code obfuscation.
    – Lundin
    Commented Sep 21, 2023 at 6:27
  • @Lundin I disagree this is something that is closable due to lack of clarity. Because the poster would be adding details that are ultimately not relevant for the question itself. "I need a regex to do <whatever>" vs starting it with "I have constraint that is <such and such> therefore, I cannot use string methods". The latter is something I'd edit out of a question for being noise.
    – VLAZ
    Commented Sep 21, 2023 at 16:58

1 Answer 1

-6

Based on the feedback I've seen in the comments, here is my attempt at refining the accepted answer to make it suitable for a help center article.

Note that I've deliberately used a non-programming example because I was unable to come up with a language-agnostic example that is easily understood.


What is an XY problem and how do I avoid it?

A question is about an XY problem if it is about an attempted solution X, and the actual problem Y is unclear. For example:

Question: How do I scrape all the burned food off my pan?

Response: How much burned food is there? How old is your pan? Is it a nonstick pan? How much cooking oil are you using?...

After a bit of back-and-forth, it might turn out that OP is using a really old nonstick pan, and the coating is worn. The ideal question which would have solved OP's problem is:

Is it time to throw away my ten-year-old nonstick pan?

In the meantime, someone could have posted an answer which explains how to scrape the food off in great detail, but this turns out unnecessary if OP should just throw away their pan.

The issue with XY problems

XY problems are often impossible to answer without follow-up questions from commenters. This can take a lot of time, and may be frustrating. It can also result in answers which are overly broad, or answers which turn out irrelevant once the underlying problem is clear.

How to avoid XY problems

It's not always easy to avoid an XY problem. If you don't know that non-stick coating doesn't last forever, the ideal question isn't obvious. However, you can ask about the general problem you're trying to solve, such as:

Is it normal that so much food gets stuck to my nonstick pan?

Also, provide all relevant details. For programming questions, this typically includes:

Even if you ask about an XY problem, other users can recognize the underlying problem if you give them enough information from the start.

4
  • 5
    The pan metaphor is wonky. What if the context that was missing from the question is "I am at work and I have to use this one pan. I have no other option. I need to scrape it off." And even if we assume OP doesn't have this problem, what if a future visitor does? When I'm actively searching for solutions, I do come up XY problems a lot where the Y perfectly matches what I need, yet the answer was for X which is not at all relevant for me. Some times OP did admit to Y being a false lead. Sometimes not, and the answerer just assumed so. It's immensely frustrating to find these.
    – VLAZ
    Commented Sep 20, 2023 at 15:48
  • 6
    "XY problems are often impossible to answer without follow-up questions from commenters" I don't think that's the case. XY problems I find are often very easily answerable. Just completely in the wrong direction. "How can I find the last three characters of a string" is fairly straight forward for a Y. The real X might be "how do I find a file extension" where the Y doesn't match correctly against the real problem: .7z files have two character extension, .docx has four.
    – VLAZ
    Commented Sep 20, 2023 at 15:51
  • 2
    Sorry, the example didn’t click for me. In an XY problem, the X is part of a (hypothetical) approach to Y; scraping food out of a pan is not part of whether it should be thrown away. Instead something like "How many slices of bacon should stick to a non-stick pan?" could be a mislead approach (the X) to having a metric for broken pans (the Y). On top of that, I am not sure that more programmers are familiar with pans than with a common programming language… Commented Sep 20, 2023 at 16:34
  • Fun fun. Let's get creative. "How do I burn down my house so the insurance will still pay for it?" -> "Uh, why are you attempting to burn down the house?" -> "There is a spider in my bedroom, I need to kill it with fire and get a new house!" -> "Maybe call an exterminator?"
    – Gimby
    Commented Sep 21, 2023 at 12:25

You must log in to answer this question.

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