4 ms·
hey seriously, i've been grappling with this: what better candidate to be a global variable than a shared cache that otherwise has to be passed through dozens o
by q845712 4y ago
hey seriously, i've been grappling with this: what better candidate to be a global variable than a shared cache that otherwise has to be passed through dozens of function calls (which imo adds cognitive load at many places through the stack).
- drakmaniso 4y agoI don't think passing state through functions calls add cognitive load: it just make it visible. Global state has the same cognitive load, except hidden. If a state is passed through dozens of function calls, this may indicate that it is shared by too many parts of the code, or that it is managed at the wrong layer of the architecture. When using global state, these potential problems are difficult to spot.
- deleted 4y ago[deleted]
- arinlen 4y ago> (...) which imo adds cognitive load (...) Choosing to ignore input data does not reduce cognitive load. You are not supposed to ignore the core function of your work, and call it a good practice.