Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

XY Problem

by jdporter (Paladin)
on Apr 10, 2006 at 18:11 UTC ( [id://542341]=perlmeditation: print w/replies, xml ) Need Help??

Every now and then I hear people say I might have an "XY problem". What is that?

"XY Problem" explanations by various people:

You want to do X, and you think Y is the best way of doing so. Instead of asking about X, you ask about Y.

from Re: sequencial file naming by Abigail

You're trying to do X, and you thought of solution Y. So you're asking about solution Y, without even mentioning X. The problem is, there might be a better solution, but we can't know that unless you describe what X is.

from Re: How do I keep the command line from eating the backslashes? by revdiablo

Someone asks how to do Y when they really want to do X. They ask how to do Y because they believe it is the best way to accomplish X. People trying to help go through many iterations of "try this", followed by "that won't work because of". That is, depending on the circumstances, other solutions may be the way to go.

from Re: Re: Re: Re: regex to validate e-mail addresses and phone numbers by Limbic~Region

To answer question Y, without understanding larger problem (the context) X, will most likely *not* help them entirely with X.

from <> by merlyn. Message can be found here.

A.k.a. "premature closure": the questioner wanted to solve some not very clearly stated X, they concluded that Y was a component of a solution, and now they're asking how to implement Y.

from <> by Alan J. Flavell

The XY problem is when you need to do X, and you think you can use Y to do X, so you ask about how to do Y, when what you really should do is state what your X problem is. There may be a Z solution that is even better than Y, but nobody can suggest it if X is never mentioned.

from <> by Tad McClellan

When people come [in here] asking how to do something stupid, I'm never quite sure what to do. I can just answer the question as asked, figuring that it's not my problem to tell people that they're being stupid. . . . But if I do that, people might jump on me for being a smart aleck, which has happened at times. ("Come on, help the poor guy out; if you know what he really need why don't you just give it to him?")
. . .
On the other hand, I could try to answer on a different level, present a better solution, and maybe slap a little education on 'em. That's nice when it works, but if it doesn't it's really sad to see your hard work and good advice ignored. Also, people tend to jump on you for not answering the question. ("Who are you to be telling this guy what he should be doing? Just answer the question.")
. . .
I guess there's room for both kinds of answer. Or maybe there isn't room for either kind.

from <6lnb70$lct$> by MJD

MJD also posted an earlier diatribe on the subject, which has become a USENET classic: Re: I never get answers to questions in newsgroups.
It has been updated several times over the years; one version appears to have been the origin of the famous "Retardo!" quote.
His latest version is on his website: TIP: How to post good questions.

Too bad that the more general problem, X, is often considered off topic for this forum. Y has more of a chance to look like a Perl problem.

from <> by bart


by me, just now.

See Also

ESR's How to ask questions the smart way includes a Q: How can I use X to do Y?

In XYZ Questions, chromatic suggests that people try to answer both the X and the Y.

On Answering Questions is an excellent article by merlyn, where he quotes this message he posted on the unix-porting mailing list.

StackExchange has a page with a rather exhaustive treatment of the topic.

We're building the house of the future together.

Replies are listed 'Best First'.
Re: XY Problem
by wfsp (Abbot) on Apr 11, 2006 at 06:12 UTC
    The proscriptive XYZ.

    I want to do X and I know you'll all tell me to use Y but I need to use Z. I can't use Y and I'm not going to explain, I have to use Z and I won't explain that either.

    update 1: Don't waste your time telling me about Y.
    update 2: Look, I have to use Z. Just tell me how to use Z.
    update 3: I give up, you're all fools

    Hope that helps :-)


      Ha! You gave my my first out-loud laugh of the day ... thanks. :) I think I saw an example of an XYZ problem of this nature just the other day, here in PerlMonks. I particularly liked update 3, very clever. Again, thanks.

      No good deed goes unpunished. -- (attributed to) Oscar Wilde
      update 2: Look, I have to use Z. Just tell me how to use Z.

      Heh. Smells like poorly-designed homework, from a prof who's more interested in following grocery lists of programming "skills" to teach than in actually teaching the skill of good programming.

      Ahhh... what you said.

      The problem I have most frequently is that I really do know I need to do Z and the explanation as to why is really not germane. But... people love to 'be smart' so they start prying.

      The trick, I suppose, is distinguishing between the two types of queries.
Re: XY Problem
by xdg (Monsignor) on Apr 10, 2006 at 21:08 UTC

    Some related problems:

    • YX Problem: You explain that you want to do X and instead of an answer you're asked "Why would you want to do X?"

    • XZ Problem: You ask how to get X to work and you're told to do Z instead.

    • XYZABC Problem: You ask how to do X and after suggesting or getting an answer Y, you get four more alternatives for doing the same thing and no way to choose between them.

    • XYZPDQ Problem: You ask how to do X and after suggesting or getting an answer Y, you get four alternatives that would be more efficient regardless of whether that is important to you or not.

    Humor aside, as Not_a_Number said, ++ for giving us an easy way to point someone to their XY Problem.


    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re: XY Problem
by merlyn (Sage) on Apr 11, 2006 at 02:10 UTC
    Then there's always the XYZ Problem:
    They ask how to do Z, but that's because they think they want to do Y and think that Z will get them there, but really it's because they're a lunkhead, and that's the main (X) problem.
    Tongue-in-cheek, of course.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: XY Problem
by rhesa (Vicar) on Apr 10, 2006 at 18:59 UTC
    And here I was thinking they were referring to my chromosomes! ;^)
Re: XY Problem
by zentara (Archbishop) on Apr 10, 2006 at 19:04 UTC
    If X and Y fail to please, just move on to the Z's :-)

    I'm not really a human, but I play one on earth. flash japh
      don't forget prophylactics
Re: XY Problem
by Not_a_Number (Prior) on Apr 10, 2006 at 19:55 UTC

    Excellent++! We can now post a succinct reply along the lines of "I think you have an XY Problem. You are asking us how to do Y, but ..."

Re: XY Problem
by eric256 (Parson) on Apr 10, 2006 at 22:39 UTC

    XYP Problem:

    You posted problem X and inquired about solution Y, but it turns out that you spelled it (P)ERL.

    Eric Hodges
Re: XY Problem
by swampyankee (Parson) on Apr 11, 2006 at 15:13 UTC

    Then there is the (thankfully rare) "my problem is X. I've tried Y." then the respondent gives a perfect solution to an entirely different problem.

    I think I'm guilty of this, at least once....


    "Being forced to write comments actually improves code, because it is easier to fix a crock than to explain it. "
    —G. Steele
      Then there is the (thankfully rare) "my problem is X. I've tried Y." then the respondent gives a perfect solution to an entirely different problem.

      I'm revising this thread to check whether a particular XY* problem may be here, and if not, then possibly add it: I noticed your entry and it occurs to me that it may be described as an XYℵ problem!

Re: XY Problem
by CountZero (Bishop) on Apr 10, 2006 at 20:59 UTC
    The ABC of the XY(Z) problem. ++


    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: XY Problem
by jeffa (Bishop) on Apr 11, 2006 at 15:14 UTC

    Completely unrelated to Perl (but still maintaining a modicum of relevance to this thread) is the YYZ Problem: you want to play the drum solo from the Rush song, YYZ, but you aren't (and never will be) Neil Peart. :/


    (the triplet paradiddle with high-hat)
      s/drum solo/bassline/;
      s/Neil Peart/Geddy Lee/;


Re: XY Problem
by gam3 (Curate) on Apr 12, 2006 at 12:24 UTC
    In case you thought this is a new problem you might want to read the first chapter of Jon Bently's book Programming Pearls (ISBN 0201657880) that was originally published in 1989. In article Cracking the Oyster starts with: "The programmer's question was simple ... my mistake was to answer his question". He then goes on to discuss how he gets at the programmer's real problem.
    -- gam3
    A picture is worth a thousand words, but takes 200K.
      New? 1989? I started programming as a H.S. student in 1965 and it wasn't much later that I first encountered and identified the problem of fellow students asking how to do something that wasn't really what they wanted to do. Later, as a professional, I learned that this was codified in the notion of requirements ... something that most hackers don't seem to know much about.
Re: XY Problem
by OfficeLinebacker (Chaplain) on Jan 07, 2007 at 00:46 UTC

    I didn't even know there was a name for this! There's a guy with whom I work who often responds to my questions with "Why don't you just tell me exactly what you're trying to do?" (meaning I do lots of XY) I just sent him an email and the format of it was

    I have problem X. Y is the way I think the solution would work, but here's a full explanation of X (and please pardon the verbosity):

    blah blah blah

    What do you think?
    I must admit to a little bit of pride for remembering how he tended to answer my questions and creating a request that (I hope) will result in better communication.
    And I think this node is really neat.

    I like computer programming because it's like Legos for the mind.
Re: XY Problem
by blazar (Canon) on May 28, 2007 at 19:32 UTC

    (Late addition)

    XWTFITL Problem: You want to do X, and you have no clue about how to do it. Instead of asking about X, you ask about... hey, WTF is that letter? (That is, something one can hardly make sense of.)

      You ask question X

      You get solution Y, which is 75% of X, the solution you really need

      Persevere and you can turn Solution Y into your solution X

      .....A die hard programmer....

Re: XY Problem
by Moron (Curate) on Apr 03, 2007 at 15:27 UTC
    This looks like an example case of the open block.


    Free your mind

Re: XY Problem
by shmem (Chancellor) on Oct 22, 2015 at 19:09 UTC

    Until now, not mentioned: the YZ problem.

    You are used to qwertz, but, at the console, your server has qwerty. Verz funnz.
    Where is the pipe char, damnit?

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      Shift plus bottom row most left key (UK mapping, not sure about US).

      My solution to the YZ problem is to use an unlabeled keyboard to avoid the eye being misled about the actual key mapping.

        (UK mapping, not sure about US).

        On the US keymap \| are where #~ are on the UK keymap.

        My solution to the YZ problem is to use an unlabeled keyboard to avoid the eye being misled about the actual key mapping.

        For the same reason I have a blank keyboard, too ;-) - and I use it mostly in the UK layout, which I found most suitable for perl programming.

        perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re: XY Problem
by wrog (Friar) on Dec 21, 2014 at 08:36 UTC

    I think my favorite statement/version of this is when it's expressed in the form:

    Some people, when they have a problem with X say,
    "I know! I'll use Y..."
    Now they have two problems.

      Yeah, that's not really the same as an XY problem, though.

        What? Yes it is.

        Plus, it's meant to be funny, and I think it is. It's just a play on a famous quote, one variant of which is

        Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://542341]
Approved by kvale
Front-paged by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-07-21 20:49 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.