News for hackers. Stuff that matters.
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.
Re:Simple Ways of Reducing the Cognitive Load in Code by amirouche on Tuesday June 28, 2016 @02:07PM (#11996044)
Me too. OOP is actually having several such states. My go to pattern is to root states in an application tree.