Bad Habbit? (variable management)
Ive noticed over the last several programs Ive written for skill building that I have certain tendencies when managing data within a program.
The biggest one that seems like a horrible habbit is my use of structures.
for example if I have 5 objects that are all similar I would throw them all in a single structure and pass them back and forth throughout the program in order to keep track of everything and make it a little bit easier (in my mind at least) to write code to manipulate.
I think it stems from only being able to return 1 value from a function. For some reason I don't want to declare anything as a global variable unless I absolutely have to for some reason.
Code:
struct SimilarData{
int group1;
int group1;
int group2;
int group2;
int group3;
int group3;
}
etc...
and then pass the entire structure to any module that uses it and then pass it back.
That really seems wrong though.
Would it be better to make it a little bit harder to read and do it in individual structures
Code:
struct group1
{
int group1;
int group1;
}
struct group2
{
int group2;
int group2;
}
or just do them all as a single variable or in an array?