I have a project in C (don't ask why but it needs to be in C), where I need to track multiple pieces of data and commands for different modules. Some actions that the program will take depend on the interactions between these different pieces of data (eg. if foo == 3 and bar == 4 do X, otherwise do Y). Some of these pieces of data will be structs grouping together similar information, some will just be primitives.
I am wondering what the best way to implement this would be. Personally, I think that each piece of data should be its own variable like so:
static int module_state;
static M1_Data module_1_data;
static int last_m1_command;
static M2_Data module_2_data;
etc...
One of my coworkers is suggesting instead that I manage everything in a super struct. His reasoning is that everything can be passed around at once if need be, and it will make it easier to track where everything is, rather than having a bunch of lose variable. His idea is for something like so:
struct{
int module_state;
M1_Data module_1_data;
int last_m1_command;
M2_Data module_2_data;
...
} SuperState;
static SuperState state
I am not sure I agree with his reasoning. What would the preferred way to handle this, and what are the upsides/downsides of both methods other than the ones listed?