We've all had the experience. You go to someone who you know has the answer to a question, ask that person the question and they answer with the typical response "why?". You explain why you need to know, and they attempt to solve your problem.
It takes time, arm twisting and patience to steer the conversation back to the original question and just get that darn answer.
Why do programmers constantly do this, and why does the behavior get worse the more senior the programmer becomes?
How can you ask a programmer a question in a way most efficient in extracting the answer to the original question?
A lot of the comments pertain to explain why the developer behaves this way, and recommend that the asker perform more research before asking the question.
There is also the situation where the developer wants to advise the developer to take another path, but I want to avoid explaining or justifying my decisions. They are unrelated to the question, but the other developer wants to make it related.
This is not an answer to the above question.
The question is specifically how does one engage with another programmer to ask a question, where the other has the answer and skip the debate about why the question is being asked.