Skip to main content
5 of 5
added 29 characters in body
Philip Couling
  • 1.5k
  • 10
  • 18

Avoiding the XY problem

I argue that you can't avoid it. Not without simply throwing your program requirements at SO and asking them to do your design for you (not recommended).

I argue this because the design process for all software is based on a starting set of requirements "A". From there you say "I can achieve A if I do B and C". From there you say "I can achieve B if I do D and E and I can achieve C if I do F and G". And that continues to the point we say that "I can achieve X if I do Y". We usually do this so fast we don't even think about the process.

So the major problem with the XY problem is that Y is not possible, but you don't know how much of your design to unwind to get back to the X which is possible. You usually don't even know that Y is impossible without actually asking. You don't know what you don't know. Therefore it is unavoidable


Asking Questions where you risk falling into XY

The best thing you can do about the XY problem is to guard against it when asking questions. Still ask the same question but give as much pertinent information as possible:

  • State your problem
  • State what you are trying to achieve
  • State how it fits into your wider design

This will help people identify that its XY and help you much more quickly.


IMPORTANT: Giving Answers to XY problems

In my opinion the biggest problem with XY questions is the (frequently) unhelpful answers they provoke. We will never stop people asking these questions so the best thing is to understand how we can answer them quickly and effectively.

Ironically a lot of these bad answers and responses are given by those wanting to be the most helpful and can be given by some of the most reputable people on the forum / SO.

I've discovered a method of answering these questions which appears to help get round the psychology associated with XY problems and lead the OP of a question to a working solution. The method takes a little longer to answer in the first instance but closes the Q/A loop much more quickly.

I suggest that you answer the question in three parts and give them in the following order.

  1. Answer the OP's question. Even though the OP probably needs something else, never neglect to answer the question they have actually asked first and not the question you think they want answered. In some cases that answer may be "Y is not possible". Too often I see responses (comments) asking "why do you need that?". This gives the OP nothing. If you say "That's going to be really hard. Explain why you need it we may be able to help" then in a lot of cases an OP will simply take the "Y is really hard" and go back to the drawing board... That's fine because you've answered their question and they may well come back with question X themselves.

  2. Discuss the OP's attempted solution. This bit's tricky and takes some thought. But I can't stress how important it is. If the OP has asked for Y and you think they want X then after answering their question (1) carry on to talking about Y (NOT X). What is Y supposed to be used for? How is it not applicable to X? The crucial thing is to carry on talking about the question but move from answering it to providing helpful information. Because after all that's what you think the OP needs. Helpful information and not the answer to their question.

  3. Solve X This is what you've been itching to do and is the whole point of your response after all. You've met the OP on their terms and answered their question. You've helped them to understand the failings of their question and why solving Y is not the thing to do... so now you're completely justified in explaining a solution to X.

Most people are here to learn so parts 1 and 2 of this answer are as important as part 3. But too often part 3 is given on it's own and it is extremely frustrating and patronising to the OP not to mention a lot of OPs will not accept the answer.

Giving this answer also avoids embarrassment when you think the OP has an XY problem when in fact they don't. All you've done is give a little extra information. Simply giving part 3 risks appearing to have not read the question.


Incidentally. Read the question again and read this answer... notice the three parts?

Philip Couling
  • 1.5k
  • 10
  • 18