I've been working at my job for about a year. I primarily do work in our GUI interface which uses methods from a C backend, but I generally don't have to deal with them except for return values. Our GUI is structured pretty reasonably, given our limitations.
I've been tasked with adding a function to the command line portion of the program. Most of these functions are like 300 lines long and difficult to use. I'm trying to gather pieces of them to get at specific alarm information, and I'm having trouble keeping organized. I know that I'm making my testing more complicated by doing it in a single long function.
Should I just keep everything in a huge function as per the style of the existing functions, or should I encapsulate the alarms in their own functions?
I'm not sure if its appropriate to go against the current coding conventions or whether I should just bite the bullet and make the code a little more confusing for myself to write.
In summary, I'm comparing
showAlarms(){
// tons of code
}
against
showAlarms(){
alarm1();
alarm2();
return;
}
alarm1(){
...
printf(...);
return;
}
EDIT: Thanks for the advice everyone, I decided that I'm going to design my code factored, and then ask what they want, and if they want it all in one I can just cut from my factored code and turn it back into 1 big function. This should allow me to write it and test it more easily even if they want it all the code in a single definition.
UPDATE: They ended up being happy with the factored code and more than one person has thanked me for setting this precedent.