Hacker News new | ask | show | jobs
by pklausler 3647 days ago
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.
1 comments

Me too. OOP is actually having several such states. My go to pattern is to root states in an application tree.