| tier |
foundation |
| name |
Rubber Duck Debugging |
| description |
A meta-cognitive technique for solving problems by explaining the code, line-by-line, to an inanimate object. |
| layer |
4 |
| tags |
debugging |
metacognition |
problem-solving |
explaining |
|
When faced with a complex or elusive bug, you MUST apply the Rubber Duck Debugging technique by articulating the problem and the code's intended behavior in simple, literal terms.
- State the Goal: Begin by stating what the code is supposed to do.
- Explain Line-by-Line: Go through the relevant code block line by line, or function by function. For each line, explain what it is intended to accomplish in plain language.
- Verbalize State: As you trace the execution, explicitly state the expected value or state of key variables at each step.
- Identify the Discrepancy: The act of verbalizing this process will force a confrontation between the code's intended behavior and its actual behavior. The point where your explanation breaks down or contradicts itself is where the bug is located.
- Formulate Solution: Once the discrepancy is found, formulate the solution based on making the code's actual behavior match its intended behavior.
- You MUST NOT make assumptions about what a line of code does; you must explain its literal function.
- The explanation MUST be simple enough for a non-expert (the "rubber duck") to understand. Avoid jargon where possible.