Trust, verify, or rewrite
Read · 1 of 3
Three choices
Trust small, familiar code you can read in one go, after a quick test.
Verify hard anything with edge cases, big inputs, money or security: test the checklist, compare with a simple version, check the speed.
Rewrite code you can't explain. If you can't say what each line does, you can't vouch for it, however confident it sounds.
Read this lesson as text
When to accept AI code, when to test it hard, and when to write it yourself.
Three choices
Trust small, familiar code you can read in one go, after a quick test.
Verify hard anything with edge cases, big inputs, money or security: test the checklist, compare with a simple version, check the speed.
Rewrite code you can't explain. If you can't say what each line does, you can't vouch for it, however confident it sounds.
Which one?
# The AI wrote 80 lines to calculate exam results for every student in your college. # The numbers look reasonable. You can't follow how it handles absent students.
What should you do?
- Ship it: the numbers look reasonable
- Verify hard, and rewrite the part you can't explain
- Ask the AI if it's correct
Show the answer
Verify hard, and rewrite the part you can't explain. Real people's results depend on it, and there's a part you can't explain. Test absent students and other edge cases directly, and rewrite what you don't understand. Asking the AI to grade itself isn't a test.
You're a code detective
You can now read code you didn't write, break it with edge cases, test it against a referee, debug it, and judge whether it's fast enough. That's the half of programming AI can't do for you.
Keep practising on the DSA roadmap: every walkthrough shows a slow solution next to a better one. Judge them before you look.