Clean Code Revisited in the Age of AI
summary
Argues that many Clean Code rules still matter but some reverse with LLMs: small one-line helpers increase hallucination because token proximity in the attention matrix decays exponentially, while single-purpose functions lower entropy and help generated unit tests. Comments become chain-of-thought scaffolding and commented-out code resurrects ghosts. Recommends a single context principle (keep related declarations together) and using mutation testing plus the CRAP index to force AI to produce covered, lower-complexity code. Warns of the lost in the middle effect for long files.
AI-written summary · about
chapters (19)
- 0:00Introduction to Clean Code
- 1:07Book's legacy and impact
- 3:56Why Clean Code still matters today
- 4:38Function arguments rules revisited
- 6:01Function size and AI attention
- 8:26Single responsibility principle
- 10:09Comments and AI behavior
- 11:52High-quality code vs low-quality code
- 13:56Commented out code dangers
- 15:21Vertical formatting and LLM focus
- 18:08Command query separation
- 19:53Law of Demeter for LLMs
- 21:59Avoiding duplication with AI
- 23:46New rule: Single context principle
- 26:54Clean Code book updates
- 27:57Practical advice for AI-friendly code
- 28:59Testing and AI-generated code
- 30:45Forcing AI to write clean code
- 32:09Conclusion and Q&A
