Skip to content
Velloreth
Programming 5 min read

Debugging in Interviews: A Practical Approach

Interviewers care about your process, not the answer. Learn the structure, the questions to ask, and the habits that signal competence.

By

What is being tested

The process, not the answer.

The interviewer wants to see:

  • A hypothesis stated before a test
  • A test that distinguishes the hypothesis from the alternatives
  • A narrowing of the search space
  • A clear narration of the state

A candidate who guesses the answer teaches the interviewer nothing.

A candidate who reasons clearly and does not reach the answer still demonstrates the skill.

The opening questions

Ask three questions before reading any code.

QuestionWhat it eliminates
Production or local?an environment difference
Every time or intermittent?a race, a cache, a load issue
What changed recently?the large majority of causes

A fourth: how many users are affected, and is it all of them or a subset.

A fifth: is there an error message, and what does the log say.

Asking these is not stalling. It is the first step of the method.

The structure

1. Restate the problem. “So a user updates their profile and the old name still shows for an hour.”

2. State a hypothesis. “I think the cache key is not invalidated on update.”

3. State the test. “I would add a log at the cache write and the cache delete, and check whether the delete fires.”

4. State the expected result. “If the hypothesis is right, the write logs and the delete does not.”

5. Narrow. “If the delete does fire, the problem is in the read path, so I would check the key construction.”

The structure is the answer. The interviewer is watching the sequence.

Narrowing by half

Add a log in the middle of the suspected path.

See which half the failure is in.

Repeat.

A binary search over the code path reaches the cause in a logarithmic number of steps.

The narration:

“The request enters the handler, so the failure is after that. I would log at the service boundary. If the service is reached, the problem is in the service or the database, and if it is not, it is in the handler or the middleware.”

This is the technique an interviewer wants to see, because it is the one that works on an unfamiliar codebase.

The tools

Name the right tool for the symptom.

SymptomTool
A wrong valuea log or a breakpoint
A slow requesta profiler, a query plan
A network failurethe network tab, a proxy
A memory growtha heap snapshot
A racea log with timestamps, a stress test
A production-only buga structured log, a trace

Mention the tool briefly. The reasoning is the point.

Being stuck

Say what you know.

Say what you have ruled out.

Say what you would try next.

A candidate who narrates the state is easy to help. A candidate who goes silent is not.

Asking for a hint after a clear summary is not a failure. It is a normal part of the work.

The phrase: “I have ruled out the handler and the middleware. I would look at the service next, and if you have a hint about the area, that would help me focus.”

The habits that signal competence

Stating the expected result before the test. This is what makes it a test.

Saying “I do not know” rather than inventing a mechanism.

Distinguishing a hypothesis from a fact. “I think” versus “I know”.

Considering the boring causes first. A typo, a stale build, a wrong environment, a missing migration.

Checking the assumption. The value that is assumed to be correct is often the bug.

Reading the error message. The whole message, including the part that is scrolled off.

Reproducing before fixing. A fix without a reproduction is a guess.

Writing the test that would have caught it. The fix is not complete without it.

The traps

Guessing the answer. No process is demonstrated.

Silence. The interviewer cannot follow the reasoning.

A test with no expected result. A poke, not a test.

Changing two things at once. The result is uninterpretable.

Ignoring the boring cause. A stale build is more common than a subtle race.

Not reading the error. The answer is often in the message.

Refusing a hint. The interview is a collaboration.

Over-explaining a tool. The reasoning is the point.

Assuming the code is correct. The assumption is often the bug.

Common mistakes

No hypothesis. A random walk.

No expected result. A poke.

Two changes at once. An uninterpretable result.

Silence. No signal.

A complex cause before a simple one. The boring cause is more likely.

No reproduction. A guess.

No test after the fix. The bug returns.

Not asking the opening questions. The search space is not narrowed.

Refusing help. A worse outcome for no benefit.

A quotable summary

A debugging interview tests the process, not the answer: state a hypothesis, state the test and the expected result, and narrow the search space by half at each step. Ask about the environment, the frequency and the recent change before reading any code, name the right tool for the symptom, and narrate the state of the investigation so the interviewer can follow and help. A wrong hypothesis stated clearly is better than silence.

For the related topics, see debugging-strategies-that-work and code-reading-strategies. For the broader context, asking-good-technical-questions and learn-programming-without-tutorial-hell.

Frequently asked questions

What is the interviewer looking for in a debugging question?
The process, not the answer. They want to see a hypothesis, a test that distinguishes it from the alternatives, and a narrowing of the search space. A candidate who reaches the answer by guessing teaches the interviewer nothing, and a candidate who reasons clearly and does not reach it still demonstrates the skill.
What should I ask first?
Ask about the environment, the frequency and the recent change. Is it production or local, does it happen every time or intermittently, and what changed recently. Those three questions eliminate most of the search space before any code is read.
How do I narrow the search space?
By halving it. Add a log in the middle of the suspected path and see which half the failure is in. Repeat. A binary search over the code path reaches the cause in a logarithmic number of steps, and it is the technique an interviewer wants to see.
What if I cannot run the code?
Say what you would log and what you expect to see. The interviewer is testing the reasoning, and a described experiment is as good as a run one. State the expected result before the experiment, because that is what makes it a test rather than a poke.
How do I handle being stuck?
Say what you know, what you have ruled out, and what you would try next. A candidate who narrates the state of the investigation is easy to help, and a candidate who goes silent is not. Asking for a hint after a clear summary is not a failure.
Should I mention the tools I would use?
Yes, briefly. A debugger, a log, a profiler, a network tab, a query plan. Naming the right tool for the symptom shows experience, and it is a signal that is easy to give. Do not spend the interview describing the tool, though; the reasoning is the point.