Re:Simple Ways of Reducing the Cognitive Load in Code
by pklausler on Tuesday June 28, 2016 @12:33PM
(#11995153)
When coding in C, I often package the state that's shared between a high-level function and its local subroutines in a local "struct context" that's instantiated in the high-level function and then passed by address as the first argument to the subroutines. Makes it easy to see what the shared state is, and adding/changing the shared state doesn't require changing all the formal and actual argument lists.
[ Parent
| on HN ]