I think it is somewhat misguided notion that code could have a property whose value is its "cognitive load". Instead we should start from the premise that:
1. Somebody writes a program
2. Somebody else (perhaps the same programmer a few years later) tries to read and understand that program
So the "cognitive load" is a property of the communication between the person who writes the program and others who read and (try to) understand the program.
Cognitive Load is an attribute of communication, not of the artifact that is the medium of the communication (i.r. the code written).
Are we writing in a "language" that readers will understand? And are we reading in a way that our assumptions about what the writer is trying communicate to us are correct?
A program is instructions to the computer. But when written in a highj-level language it is also meant to be read by other prrogrammers, not just by the CPU. It is human-to-human communication. How easy is it for somebody to understand what somebody else is trying to tell the computer to do? That's the "Cognitive Load".
Right, I was just trying to bring up the point that however the code is written, what really matters is, how easily humans can understand it.
Now maybe there is, or can be an algorithm that takes a piece of code and spits out a number saying how easy it is for a typical programmer to understand it correctly. That would be the measure of "cognitive load".
If we just speak of cognitive load without really specifying how to measure it, we are not where we would like to be.
How do we define, and measure "cognitive load"? It is an easy word to use, but how to measure it?
1. Somebody writes a program
2. Somebody else (perhaps the same programmer a few years later) tries to read and understand that program
So the "cognitive load" is a property of the communication between the person who writes the program and others who read and (try to) understand the program.
Cognitive Load is an attribute of communication, not of the artifact that is the medium of the communication (i.r. the code written).
Are we writing in a "language" that readers will understand? And are we reading in a way that our assumptions about what the writer is trying communicate to us are correct?
A program is instructions to the computer. But when written in a highj-level language it is also meant to be read by other prrogrammers, not just by the CPU. It is human-to-human communication. How easy is it for somebody to understand what somebody else is trying to tell the computer to do? That's the "Cognitive Load".