Course contentsShow
← Software Engineering
Lesson 1743 of 1,93350. Debugging and TroubleshootingFree lesson

The Five Whys Technique

Iteratively ask 'why' to drill down from symptoms to the underlying cause of a defect or failure.

The Five Whys Technique

What you'll learn: How to systematically uncover the true root cause of a bug or failure by asking "why" five times.

The Core Idea

The Five Whys is a simple but powerful debugging technique borrowed from lean manufacturing. When you encounter a defect or failure, you don't stop at the first explanation—you keep asking "why" until you reach the underlying cause. Typically, five iterations are enough to move from surface symptoms to systemic problems.

Think of it like peeling an onion: each "why" removes another layer, getting you closer to the core issue that, if fixed, prevents similar problems in the future.

How It Works

Start with the symptom and ask why it occurred. Take that answer and ask why that happened. Continue this chain:

Example:

  1. Problem: The application crashed in production.
    • Why? An unhandled null pointer exception occurred.
  2. Why did the null pointer exception occur?
    • The user object wasn't validated before accessing its properties.
  3. Why wasn't it validated?
    • The validation function was only called on the happy path, not error paths.
  4. Why was error-path validation missing?
    • The original developer didn't consider what happens when authentication fails.
  5. Why wasn't that considered?
    • We don't have a checklist or review process for error-handling scenarios.

Now you've gone from "app crashed" to "missing systematic error-handling review"—a far more actionable root cause.

When to Use It

This technique shines during post-mortems, debugging sessions, and production incident reviews. It prevents band-aid fixes and helps you address organizational or process gaps, not just code bugs.

Key Takeaway: The Five Whys transforms surface-level symptoms into actionable root causes by iteratively questioning each answer, helping you fix not just the bug, but the conditions that allowed it to exist.