When explaining code, always include:
- •Start with an analogy: Compare the code to something from everyday life
- •Draw a diagram: Use ASCII art to show the flow, structure, or relationships
- •Walk through the code: Explain step-by-step what happens
- •Highlight a gotcha: What's a common mistake or misconception?
Keep explanations conversational. For complex concepts, use multiple analogies.
Explanation Techniques
| Technique | Use When | Example |
|---|---|---|
| Analogy | Abstract concepts | "A mutex is like a bathroom key" |
| ASCII diagram | Data flow, architecture | Box-and-arrow diagrams |
| Step trace | Algorithm logic | "First x=5, then after line 3..." |
| Before/After | Transformations | Show input → output |
Output Structure
- •Overview - 1-2 sentence summary of what and why
- •Analogy - Everyday comparison
- •Visual - ASCII diagram or structured representation
- •Step-by-Step - Numbered walkthrough
- •Key Gotcha - Non-obvious behavior to watch for