So, this is yet another 'good' programming practice question. I did search around a bit, but something like this is often hard to define in just a few words.
To the question: from a professional perspective, is it better programming practice to keep code streamlined and short (not necessarily more efficient) or to explicitly define instance variables only to assign them and immediately return? For example:
FILE * foo(){
FILE * retVal;
foo2();
retVal = foobar();
return retVal;
}
From the above, we can see immediately that foobar returns a FILE *. So, from this style of programming we can more quickly extract important information. This is true compared to something like this:
FILE * foo(){
foo2();
return foobar();
}
Which, of course, accomplishes the same thing. However, one must look more deeply to find the same information. I tend to favor the latter style of programming simply for the reason that it looks better. Due to the nature of how this program will run, I doubt there are any immediate performance gains from using either one since memory is still necessary for either choice - the difference is whether or not the user or the compiler allocates it.
As another example of keeping code short and concise:
int foo(){
int i = 0;
while(foobar())
i++:
return i;
}
TL:DR Question >> Is it better to explicitly show what is being done, or is it okay, in favour of brevity and conciseness, shorten code that accomplishes the same task but does not necessarily provide performance gain?
Usually, with proper optimization turned on, compilers will optimize out most of the redundant or dead part and make the binary as efficient as possible.
Keeping that in mind, it is advised that to write code which is easily understandable for humans. Leave the optimization part (mostly) to the compiler.
Writing a code which is more understandable by humans, makes it
PUNFUN intended)