AI Coding: Programming by Coincidence at Scale
In The Pragmatic Programmer, the authors describe Programming by Coincidence: writing code that appears to work without understanding why.
I think AI-assisted coding makes this problem even more relevant.
With AI, we can generate hundreds of lines of code in seconds. We run it, see the expected output, and move on. But do we actually understand why it works?
The danger is that AI allows us to accumulate code we don’t understand much faster than before. When something eventually breaks, we’re left debugging a system whose assumptions and behavior we never fully understood.
The problem isn’t that AI writes code. It’s that we mistake working code for correct code.
So how do we avoid this?
- Define expected behavior first. Know what the code should do before asking AI to implement it. (Start with SPEC.md)
- Understand the reasoning. Question important design decisions and assumptions. (When AI generates lots of code, you should ask AI’s reasoning.)
- Test failure cases. Don’t just verify the happy path. (Start with TDD)
- Keep changes small. Review and validate incrementally. (Break SPEC.md into smaller tickets)
- Own the result. Don’t ship critical code you can’t explain or maintain. (For business critical part of code, If the AI generated code is not readible by you, then rewrite to be understandable by YOU. Asking for diagram & flow chart isn’t sufficient. Longer + Understandable code is better than Concise + hard-to-follow code.)
AI can accelerate implementation, but it doesn’t replace engineering judgment.
If we don’t change how we verify and understand code, we’re just programming by coincidence, faster.
Share on
Twitter Facebook LinkedInKeep reading
🛠️ More in Engineering
-
What’s inside that token? JWT explained with a boarding pass
· 7 min read
AI-researchedI built an OAuth 2.0 server with Keycloak for our MCP setup. Here is what a JWT actually carries — issuer, audience, roles — and how we pack our own facts into it: environment, customer, and...
-
Job Applications with AI: My Cover Letter Generation Agent
· 1 min read
The ProblemWriting cover letters sucks. Each one took me 45+ minutes of:
-
Keycloak Components: Roles, Scopes, Client Scopes, and Audience
· 7 min read
AI-researchedA simple explanation of how Keycloak controls access from an app to an SSH MCP server.
-
Attention has four matrices, not three
· 13 min read
AI-researchedQ, K, V, and the output projection the name leaves out. What each weight does to the same input, and why the differences between them decide what an inference server has to cache.