• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

#ActualBacterius

Posted 04 October 2012 - 11:01 PM

I also don't like white space everywhere.

if((doSomething(stuff,moreStuff)&&!didSomethingAlready)||(didSomethingAlready&&noNeedToDoMore&&overrideAlreadyDidSomething(manager.name.c_str())))

Yup, much nicer. Seriously, I have seen stuff like this in code. And yet they wondered why so often bugs appear. Being an anarchist and breaking all rules may be fun to do for a bit, trying to get up with a working program that abuses operator overloading like mad and consists of code that when you look at it looks like a pacman made of code and whitespace. But mostly guidelines are there for a reason. Of course, they are guidelines for a reason as well, break them if you have to, but you need to be able to defend your decision to break them.

There should be spaces between non-unary operators and after commas, but there should not be a space after an opening bracket nor before a closing one. Just like in typography. The case of wrapping an unary operator like negation between brackets is arguable, it's a common mathematical convention that unary operators take precedence over just about anything else, but this can be violated in programming languages with preprocessor rules, prefix/postfix operators, or other stuff. Thus:
You can also use newlines to make the || operator terms more visible, or even break the condition into two different conditions based on didSomethingAlready. Or just use shorter function names and less conditions.There is always a solution.

People who put redundant brackets with extra spaces inside them and before semicolons, and deliberately omit spaces around assignment operators drive me insane! I see this kind of code all the time in VB and Java code for some reason:
[source lang="cpp"]if( ( myCondition )==MY_DEFINE ){return ( ~myCondition*2+(1+1) ) ;}[/source]

#1Bacterius

Posted 04 October 2012 - 11:00 PM

I also don't like white space everywhere.

if((doSomething(stuff,moreStuff)&&!didSomethingAlready)||(didSomethingAlready&&noNeedToDoMore&&overrideAlreadyDidSomething(manager.name.c_str())))

Yup, much nicer. Seriously, I have seen stuff like this in code. And yet they wondered why so often bugs appear. Being an anarchist and breaking all rules may be fun to do for a bit, trying to get up with a working program that abuses operator overloading like mad and consists of code that when you look at it looks like a pacman made of code and whitespace. But mostly guidelines are there for a reason. Of course, they are guidelines for a reason as well, break them if you have to, but you need to be able to defend your decision to break them.

There should be spaces between non-unary operators and after commas, but there should not be a space after an opening bracket nor before a closing one. Just like in typography. The case of wrapping an unary operator like negation between brackets is arguable, it's a common mathematical convention that unary operators take precedence over just about anything else, but this can be violated in programming languages with preprocessor rules, prefix/postfix operators, or other stuff. Thus: