The project is full of such code and the function is really long and hard to understand.. How to refactor?
int get_greate_structure(GreateStructure* st)
{
switch (st->type)
{
case 1:
do_some_business_and_fill_part_of_the_st();
break;
case 2:
do_other_things_and_fill_part_of_the_st();
break;
case 3:
break;
...
case 1000:
...
}
}
void fn()
{
GreateStructure *st = AllocateGreateStructure();
st->do_case_1 = true;
get_greate_structure(st);
// we did the case 1 and get some data we need..
}
enums
. – MichaelT Jan 31 at 15:37get_greate_structure
is already working then you shouldn't have to look at it. – resting Jan 31 at 15:49