Earlier quoted context omitted.
I disagree, what is "saved" is your time when reading/understanding... why spend time to read 10 lines and figure out that it actually does what a simple ternary operation would accomplish?? On that same vein, if a ternary operation is going to throw someone for a loop, I've got some bad news about their career in programming.
These are both extremes and both bad. The 10 line switch statement to switch a variable is a high cognitive load for no good reason but so is a nested ternary under pretty much any circumstances, but especially with single character variables and magic numbers. >On that same vein, if a ternary operation is going to throw someone for a loop, I've got some bad news about their career in programming. You're right about…
Exactly.
The bigger constructs expressed in functions, classes, etc, are where the attention should really be.
The smaller ideas expressed in single lines of code are, should be, insignificant in terms of cognitive load.
There are some exceptions to this, in particular very high performant code. We all know that "premature optimization...".