In my experience, programmers tend to be intelligent. But some of the smartest developers I’ve known write rotten code. My hypothesis is that their mental acuity gives them too high a tolerance for complexity. This can be a problem for we less-gifted folks who are trying to make sense of their code.
This dovetails with another of my my unproven theories, which regards mental capital. I have the notion that we have a finite amount of problem-solving capacity. If we spend too much of it to follow poorly formatted code, lengthy functions, complicated state, and the like, we’ll have less mental capital available to solve important problems, such as detecting logic errors.
The fact that I ought to be able to suss out a tricky or sloppy bit of code does not mean that you should force me to do it.
Edsger Dijkstra made a similar point in The Humble Programmer, CACM 1972:
The competent programmer is fully aware of the limited size of his own skull. He therefore approaches his task with full humility, and avoids clever tricks like the plague.
This notion of “mental capital” and the perils of wasting it seems consistent with the psychological concept of “decision fatigue“, the deteriorating quality of decisions made by an individual after a long session of decision making. It is now understood as one of the causes of irrational trade-offs in decision making.