Live data from Hacker News

The XY Problem (2014)

xyproblem.info

91–100 of 105 posts

Re: The XY Problem (2014)

#91
The essay "Cracking the Oyster" from Programming Pearls is one of the early recorded instances of the XY problem. The "looking to solve the problem I think I have rather than the one that I actually have" goes back to some of the early days of programming.

( The following portion can be found at https://tfetimes.com/wp-content/uploads/2015/04/ProgrammingP... and in a less accessible format at https://archive.org/details/ProgrammingPearls2ndEditionJonBe... )

> Column 1: Cracking the Oyster The programmer’s question was simple: “How do I sort a disk file?” Before I tell you how I made my first mistake, let me give you a chance to do better than I did. What would you have said?

> 1.1 A Friendly Conversation

> My mistake was to answer his question. I gave him a thumbnail sketch of how to implement a Merge Sort on disk. My suggestion that he dig into an algorithms text met with less than enthusiasm — he was more concerned about solving the problem than furthering his education. I then told him about a disk sorting program in a popular programming book. The program consisted of about two hundred lines of code in a dozen functions; I estimated that implementing and testing the code would have taken the programmer at most a week.

> I thought that I had solved his problem, but his hesitation led me back to the right track. The conversation then went something like this, with my questions in italics.

> Why do you want to write your own sort at all? Why not use a sort provided by your system?

> I need the sort in the middle of a large system, and for obscure technical reasons, I can’t use the system file-sorting program.

> What exactly are you sorting? How many records are in the file? What is the format of each record?

> The file contains at most ten million records; each record is a seven-digit integer.

> Wait a minute. If the file is that small, why bother going to disk at all? Why not just sort it in main memory?

> Although the machine has many megabytes of main memory, this function is part of a big system. I expect that I’ll have only about a megabyte free at that point.

> Is there anything else you can tell me about the records?

> Each one is a seven-digit positive integer with no other associated data, and no integer can appear more than once.

> The context makes the problem clearer. In the United States, telephone numbers consist of a three-digit “area code” followed by seven additional digits. Telephone calls to numbers with the “toll-free” area code of 800 (the only such code at the time) were not charged.

> The programmer was building a small corner of a system for processing such a database, and the integers to be sorted were toll-free telephone numbers. The input file was a list of numbers (with all other information removed), and it was an error to include the same number twice. The desired output was a file of the numbers, sorted in increasing numeric order. The context also defines the performance requirements. During a long session with the system, the user requested a sorted file roughly once an hour and could do nothing until the sort was completed. The sort therefore couldn’t take more than a few minutes, while ten seconds was a more desirable run time.

> 1.2 Precise Problem Statement

> To the programmer these requirements added up to, “How do I sort a disk file?” Before we attack the problem, let’s arrange what we know in a less biased and more useful form.

> ...

> 1.5 Principles

> The programmer told me about his problem in a phone call; it took us about fifteen minutes to get to the real problem and find the bitmap solution. It took him a couple of hours to implement the program in a few dozen lines of code, which was far superior to the hundreds of lines of code and the week of programming time that we had feared at the start of the phone call. And the program was lightning fast: while a Merge Sort on disk might have taken many minutes, this program took little more than the time to read the input and to write the output — about ten seconds. Solution 3 contains timing details on several programs for the task.

> Those facts contain the first lesson from this case study: careful analysis of a small problem can sometimes yield tremendous practical benefits. In this case a few minutes of careful study led to an order of magnitude reduction in code length, programmer time and run time. General Chuck Yeager (the first person to fly faster than sound) praised an airplane’s engine system with the words “simple, few parts, easy to maintain, very strong”; this program shares those attributes. The program’s specialized structure, however, would be hard to modify if certain dimensions of the specifications were changed. In addition to the advertising for clever programming, this case illustrates the following general principles.

> The Right Problem. Defining the problem was about ninety percent of this battle — I’m glad that the programmer didn’t settle for the first program I described. Problems 10, 11 and 12 have elegant solutions once you pose the right problem; think hard about them before looking at the hints and solutions.

---

I highly recommend the book as it makes you think which was especially important in the days of the limited resources of early computing. And while we are spoiled now with powerful processors and plentiful memory we shouldn't let that make us lazy in our designs.

Re: The XY Problem (2014)

#92

IMO the XY problem problem eclipsed the XY problem in significance a while ago. Q&A communities are full of useless XYsplaining that pollutes search results with non-answers. If you know the answer to someone's question, and you want to be helpful and informative, then simply answer it. Follow your answer with "why do you need this btw? there might be a better approach" when appropriate. This is Example 1 from the OP…

I think the best way to avoid the XY problem problem is to give two answers. First, stating the short answer to the assumed question, then the long answer to the explicit question. So, if somebody asks how they can access private member variables in C++, the first answer would say how to avoid needing to in the first place, and the second answer would say to buckle up because it’s time for the fun world of undefined-…

Given time as a limited resource, how much time do you want to spend on the long answer if it isn't going to help the person asking the question (assuming that the person asking the question isn't after an education and is more interested in "just solve my problem")?

Back when I was answering questions on one of the SE sites my rule of thumb for how much I was going to invest in answering a question was based on how much it appeared that the person invested in research and asking the question.

If they had only appeared to have spent a few minutes on asking the question and the answer was something that would have taken much longer to properly answer, I'd pass on answering and may only leave a comment asking for more information about the nature of the problem so that another person coming by later to answer it would not need to do as much research into providing an answer themselves.

Re: The XY Problem (2014)

#93
post #67

Earlier quoted context omitted.

I'm sorry, but if people often do this to you, maybe reflect on them actually being right? Or that you're legitimately asking a stupid question given your self-proclaimed lack of expertise? People don't answer that way to be smug or so. They do it because the thankless person they're spending their own free time helping will just come back with a new asinine question the moment one answers their posed question. It's…

Did you reflect on the case that actually you might be the smug one in this scenario, assuming that every person who asks a question doesn’t know what they are talking about, and you know better than them? I have experienced this many times, and it’s extremely frustrating, when people ask for the context, and I answer something to the effect of: > the context is quite hard to explain but I assure you I thought throug…

The simplest way I can put it is, be careful that you're not rationalizing when you ought to be reasoning.

The former is the main source of the XY problem, and comes up very often in cases where people are stuck and asking for help. The main issue they would be having is that they're framing the problem incorrectly in their heads and working through the logic of the ideal solution based on faulty grounds.

I would like to point out the subtle irony in responding to these comments with a meta-scale XY problem: you think your problem is other people don't see the Y for what it is (people don't understand my questions are really about Y and not about X), while you are yourself blind to the X (I may not be framing my problem correctly in my mind which is leading to my overconfidence that it is Y and not X).

Re: The XY Problem (2014)

#94

Earlier quoted context omitted.

I'm sorry, but if people often do this to you, maybe reflect on them actually being right? Or that you're legitimately asking a stupid question given your self-proclaimed lack of expertise? People don't answer that way to be smug or so. They do it because the thankless person they're spending their own free time helping will just come back with a new asinine question the moment one answers their posed question. It's…

> they're spending their own free time helping Oh, man, if it's such a bother, just don't. Nobody is forcing you to spend your own free time. But well, let's be clear. This is a Stack Overflow problem only. And it's Stack Overflow only because every interaction on that site includes a veiled threat of "do what I say or I'll make sure nobody ever answers your question and you are blocked away from this site". Any unre…

> This is a Stack Overflow problem only.

Were this only to be true. I first encountered this issue on a coding forum before StackOverflow even existed. Though the term XY problem hadn't been coined yet, there was a regular poster who would come in and accuse people of asking the wrong question. Someone would ask how to make an HTTP connection in Objective-C and he'd explain that Objective-C was the wrong tool for that job and that they should be using C#. The poster would then explain that they were writing an iPhone app, ruling out C# in early 2008, but he would then explain that an iPhone app was the wrong tool for the job and that the poster should be writing a Windows desktop app. Someone would point out that making an iPhone app was a decision made at the CEO level and beyond their capacity to change and this fellow would say that they should quit their job and work for a company that makes desktop apps for Windows.

Re: The XY Problem (2014)

#96
post #8

I often encounter the opposite. I would have a complex problem that I can legitimately solve by something reasonably simple yet I don’t posses the expertise on. Asking how to do Y, I need to spend an godawful amount of time wasting to convince people that no, it really is not an XY problem, and could we just focus on the literal problem description, which you could answer in like 3 minutes, instead of you trying to s…

[deleted]

Re: The XY Problem (2014)

#97
post #67

Earlier quoted context omitted.

I'm sorry, but if people often do this to you, maybe reflect on them actually being right? Or that you're legitimately asking a stupid question given your self-proclaimed lack of expertise? People don't answer that way to be smug or so. They do it because the thankless person they're spending their own free time helping will just come back with a new asinine question the moment one answers their posed question. It's…

Did you reflect on the case that actually you might be the smug one in this scenario, assuming that every person who asks a question doesn’t know what they are talking about, and you know better than them? I have experienced this many times, and it’s extremely frustrating, when people ask for the context, and I answer something to the effect of: > the context is quite hard to explain but I assure you I thought throug…

> the context is quite hard to explain but I assure you I thought through this question and this is precisely what I need to know

Oh man, I field questions on a technical subreddit, and you wouldn't believe the sheer number of non-expert askers who confidently believe this. It doesn't take much follow-up to realize that not only is the context easy to explain for anyone who truly understands it, but the asker is actually asking about X.

You are one in a million, congrats. The vast majority of people who say what you said are bringing their own arrogance, simultaneously accepting that they need help while preparing to reject the help of the actual experts they are appealing to.

> “this seems like a strange question because X, but here is the answer”

This is a good first response and how I answer suspected XY Problems. It often leads to the asker reevaluating their assumptions, which is a valuable teaching moment and the goal if my true motivation is to help people.

Re: The XY Problem (2014)

#98

Earlier quoted context omitted.

Yeah the whole premise of the "XY" problem seems like it was written up by someone who regulars Stack Overflow. It's pretty frustrating when the highest-upvotes answer to a question is "actually you don't want to do that. do something else instead".

The goal of asking a question is not to get the exact answer to the words you spoke, it is to solve the problem the question is inspired by. It's a funny psychological thing, though, where people perfectly comfortable with the idea they don't know the answer to a question are easily offended by the implication that they don't know what question would lead to a solution, even though the foundational knowledge to answe…

People are OK with what they know they don't know, as no one knows all the "trivial details", but not OK with what they know being wrong.

Re: The XY Problem (2014)

#99

Earlier quoted context omitted.

[flagged]

> Using chocolate-covered bananas to integrate European currency systems is a metaphorical scenario, so let's explore it creatively. > Remember, this creative exercise is not a practical strategy for integrating European currency systems Sounds like it XYed you.

It most certainly did not. XY'ing me would be stating that the question is a waste of my and their time and an answer wouldn't help me and then choosing not to answer, as was the suggested approach. It is pompous and shitty behavior so call it what it is.

Re: The XY Problem (2014)

#100
post #67

Earlier quoted context omitted.

Did you reflect on the case that actually you might be the smug one in this scenario, assuming that every person who asks a question doesn’t know what they are talking about, and you know better than them? I have experienced this many times, and it’s extremely frustrating, when people ask for the context, and I answer something to the effect of: > the context is quite hard to explain but I assure you I thought throug…

> > the context is quite hard to explain but I assure you I thought through this question and this is precisely what I need to know I dunno, I mean, to me this just sounds like the "senior developer" phrasing of the same logic that the noob was using in the linked page. The core problem is that you don't know what you don't know, right, and no one is immune to that, regardless of age or experience. IMO that we should…

In some cases the context is hard to explain because it's complex, or it relates to something about the domain of the use-cases which is very particular to this implementation. If all you need is some small detail, like how to accomplish something with X library, it would be a waste of everyones time to write several paragraphs to explain some context which will be irrelevant to everyone else.
Post reply on HN