Writing good code: how to reduce the cognitive load of your code
Whenever I read articles like this and the ensuing discussion that follows, I&#x27;m reminded of this quote from Dijkstra:<p><i>Don&#x27;t blame me for the fact that competent programming, as I view it as an intellectual possibility, will be too difficult for &quot;the average programmer&quot; — you must not fall into the trap of rejecting a surgical technique because it is beyond the capabilities of the barber in his shop around the corner.</i><p><i>Dijkstra (1975) Comments at a Symposium</i><p>Whenever I read code written in the &quot;so boring it cannot fail&quot; camp I get exhausted. This code is inherently procedural and rolls itself into a giant ball of mud -- composition is difficult to achieve so as requirements change the code accrues more loops and conditionals until it is nearly incomprehensible.<p>It might start out neat and clean but rarely will it stay that way.<p>Good, non-leaky abstractions are key. This can even be achieved with procedural code but I think functional programming techniques like pure functions, immutable values, and a sound type system help a great deal... even at the expense of the initial &quot;cognitive load,&quot; it takes to learn how to employ these tools.