RoleGymAIinterview performance
All articles
Technical interviews

Debugging Interview Practice: Explain Your Steps When the Code Fails

Practise debugging in an interview with a fictional checkout bug, a spoken evidence ladder, and a checklist for explaining tests and next steps.

5 min readBy RoleGymAI

Debugging interview practice is not about guessing the bug fastest. It is about showing a repeatable sequence: restate the observed failure, make a small hypothesis, collect evidence, change one thing, and verify the fix and its boundaries.

That sequence gives an interviewer something more useful than a stream of guesses: they can see how you work when the first idea is wrong. Microsoft describes technical interviews as assessing both relevant technical principles and how candidates approach problem-solving and new challenges in its technical-interview guidance. A clear debugging narration makes that approach audible.

Use an evidence ladder, not a list of possible causes

When code fails, it is tempting to name every cause you can think of. In an interview, that can sound like random searching. Instead, move up an evidence ladder:

  1. Observed behavior: What happened, for which input, and what did you expect instead?
  2. Smallest reproduction: Can you make the failure happen with a tiny input or one request?
  3. Boundary: Which layer is behaving unexpectedly: input, logic, stored data, response, or display?
  4. Hypothesis: What specific condition would explain the evidence so far?
  5. Check: What log, test, trace, or inspection would confirm or rule it out?
  6. Fix and verification: What changed, which original failure now passes, and what nearby case could still break?

You do not need to announce the headings. A concise spoken answer can sound like: “I can reproduce it with an empty cart. Before changing code, I would inspect whether the total is calculated before the quantity validation. If that is true, I would add the guard, then rerun the empty-cart and one-item cases.”

Worked debugging interview example: a fictional checkout total

Example — fictional scenario: A shop's checkout page shows NaN as the total only when a customer removes the last item. The relevant function is:

function cartTotal(items) {
  return items.reduce((sum, item) => sum + item.price * item.quantity);
}

Here is how to narrate the investigation instead of jumping directly to the answer.

Step 1: State the failure precisely

“The failure happens after the last item is removed, so I would first compare cartTotal([]) with cartTotal([{ price: 10, quantity: 1 }]). I expect zero for an empty cart, not NaN.”

That first sentence proves that you have turned a vague report into a testable case. It also avoids assuming whether the bug begins in the UI, the API, or this function.

Step 2: Form one testable hypothesis

“If the empty-array case fails while the one-item case works, I would check whether reduce has an initial accumulator. Without one, there is no numeric starting value for an empty collection.”

The key phrase is if. Good debugging separates what you know from what you are about to test.

Step 3: Make the smallest safe correction

function cartTotal(items) {
  return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}

“I would start the accumulator at zero. Then I would run the empty-cart case again and check a one-item and multi-item cart to make sure the ordinary path did not change.”

Step 4: Name the nearby risk

“Next I would check whether price and quantity are always numbers. If the API can send strings or missing values, the same display could return for a different reason, so I would validate at the boundary rather than treat this change as a universal fix.”

This last step distinguishes a fix for the reproduced defect from an unsupported claim that the system is now perfect.

A spoken debugging template

Use this template with any exercise or real project:

What I observe: [actual result] for [smallest input].
What I expect: [expected result].
First boundary to check: [input / logic / data / response / UI].
Hypothesis: If [condition] is true, it would explain [evidence].
Check: I would inspect or test [specific signal].
Change: I would [smallest change] only after that check.
Verify: I would rerun [original case] plus [two nearby cases].
Remaining question: [risk or assumption to investigate].

The template is deliberately short. It keeps the explanation anchored to evidence and leaves room for the interviewer to ask why you chose a particular test.

Avoid four weak debugging habits

Changing several things before checking

If you alter validation, a query, and the UI together, you cannot tell which change mattered. In an interview answer, choose the next smallest reversible check. In a real production system, follow the team's safety and review process rather than treating an interview exercise as permission to edit live data.

Treating logs as an explanation

A log line is evidence, not a conclusion. Say what it would answer: “I would log the item count and calculated total at this boundary to see whether the bad value arrives before or after calculation.”

Forgetting the original failure after the fix

The exact input that failed is the first test to rerun. Then add adjacent cases: empty input, one valid input, and a malformed input where appropriate. Microsoft also advises candidates to test their own and teammates' code in technical interviewing; saying how you test makes the fix more credible. Microsoft technical interviewing

Narrating every keystroke

An interviewer cannot learn much from “then I click this file.” Narrate decision points instead: what you would inspect, what would change your mind, and what you would verify.

A 10-minute debugging rehearsal

Pick a small failure from a practice project, a coding challenge, or the fictional example above. Set a timer and do three rounds:

  1. Spend two minutes writing the observed behavior and three candidate boundaries.
  2. Spend three minutes saying the evidence ladder aloud without opening the code.
  3. Spend five minutes checking the code or tests and correcting any claim that was only a guess.

If you get stuck, do not fill the silence with an invented explanation. Use a bounded recovery sentence: “I do not yet know whether the value becomes invalid at input or during calculation. I would make the smallest reproduction and inspect that boundary first.” That is a stronger demonstration of judgment than a confident but false answer.

For a broader rehearsal structure, pair this drill with the 90-second project walkthrough in How to Explain a Coding Project in an Interview. Save the real project context and the two debugging prompts you want to practise in RoleGymAI Interview Preparation, then rehearse them aloud before the interview.

Find more practical interview exercises on the RoleGymAI blog.