Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What stirs your rage, /prog/?

Name: Anonymous 2013-09-14 1:07

Mine are people who do this on C-like languages:
if(numbers==NULL)
{
numbers=temp;
numbers->next=NULL;
}
else
{
temp2=numbers;
while(temp2!=NULL)
{
var=temp2;
temp2=temp2->next;
}
temp2=temp;
var->next=temp2;
temp2->next=NULL;
}


No spaces between operators.
Opening brace on lines by themselve.
Else statement not a continuation of the if-statement it belongs to
Terse variable.
camelCase

Name: Anonymous 2016-10-26 2:05

People who use if/else blocks instead of early returns.

i.e. instead of writing all your fucking code in the else block like this:

if (foo) {
x += 1;
} else if (bar) {
x += 3;
} else {
/* huge pile of shit */
}


Write it like this

if (foo) {
x += 1;
return;
} else if (bar) {
x += 3;
return;
}

/* huge pile of shit */


Now the trivial cases are dealt with early, the main body of the function isn't indented at all, and your coworkers are less pissed off at you. Everybody wins.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List