News:

Come Chat with us live! Learn how HERE!

Main Menu

What indentation style do you prefer?

Started by /dev/humancontroller, July 12, 2007, 06:14:14 AM

What indentation style do you prefer?

one tab per block depth
11 (68.8%)
two spaces per block depth
2 (12.5%)
four spaces per block depth
3 (18.8%)
other
0 (0%)

Total Members Voted: 15

Voting closed: July 12, 2007, 06:14:14 AM

/dev/humancontroller

I mean, of course, for the majority of the code, because slight mixing can be acceptable/good.
I ask this, because the stock version has one style in one file, and another style in another file. And I hate one of them, which I won't tell. Let's see...

I you have explanations, go ahead and write.

David

4 spaces for me.
Although tabs are best, as they let each dev have it how they want.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

tehOen

indentation is for the losers I code everything in 1 line

benmachine

I hate Tremulous code's spaces around EVERYTHING.
Spacing is mostly good, but when it's even sometimes inside [] it can seem excessive and just as confusing as no spacing at all.
Yeah, and I voted four spaces.
benmachine

Ingar


/dev/humancontroller

Quote from: benmachineI hate Tremulous code's spaces around EVERYTHING.
Spacing is mostly good, but when it's even sometimes inside [] it can seem excessive and just as confusing as no spacing at all.
Yeah, and I voted four spaces.
What looks good for me:
thaip funkshun( war neim, thaip_t twu, ... )
asd[0], qwerty[1337]
anotherLong.struct[ referenceWith->everything ].inside // space in [] when something long is in it

do you even disagree with these?

/dev/humancontroller

Quote from: IngarIndentation is for code beautifiers
http://astyle.sourceforge.net/

I use tabs myself.
Sample result code plz?

Ingar

Quote from: /dev/humancontroller
Sample result code plz?

Before:
int main(int argc, char ** argv) {
int a;
if (cin >> a)
{
cout << a << endl;
if (cin >> a)
{
cout << a;
}
}
return  0;
}

Command:
astyle --style=linux example.cpp
After:
int main(int argc, char ** argv)
{
       int a;
       if (cin >> a) {
               cout << a << endl;
               if (cin >> a) {
                       cout << a;
               }
       }
       return  0;
}

David

I hate people who put the opening { on the same line as what it opens.
The { and } should line up!
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

tehOen

omg formatting doesnt matter as long as it is readable
it is just a convention
btw ansi FTW

/dev/humancontroller

Quote from: DavidI hate people who put the opening { on the same line as what it opens.
The { and } should line up!
Do you hate me more than my style? :D
I accept that style because the indentation shows that you're in a new block.

The compactness of the code is also a requirement. When we have to execute 1 conditional statement, like a return, here are the options:
if( some > condition ) {
return;
}
// Allows you to quickly add debug lines like Com_Printf( "ZOMGWUTDAFUK\n" );
// Remove the braces once the program has been tested.

if( some > condition )
return;
if( some > condition ) return;
// Uh... these two are kind of interchangable,
// chose the second one if compactness is the first priority.

if( some > condition )
{
return;
}
// Does this make it better?


OK, if more than 1 statement is inside, blocks are required.
if( right ) {
right[0] = -1*sr*sp*cy+-1*cr*-sy;
right[1] = -1*sr*sp*sy+-1*cr*cy;
right[2] = -1*sr*cp;
}
if( up )
{
up[0] = cr*sp*cy+-sr*-sy;
up[1] = cr*sp*sy+-sr*cy;
up[2] = cr*cp;
}
// Well, the second one is less compact, but more readable.
// Wether the first or the second block is better, I don't know.

// What about this? eeewww
if( forward ) {

forward[0] = cp*cy;
forward[1] = cp*sy;
forward[2] = -sp;
}

Kaleo

2. Or 3 sometimes.
//Fuck this shit...
{
 printf "I am";
 printf " listening to";
 printf " ManOwaR!";
}
Quote from: Stannum
Thou canst not kill that which doth not live,
but you can blow it into chunky kibbles!
I has a cookie, and u can has a cookie, but i no givs u mai cookie...

Undeference

Need help? Ask intelligently. Please share solutions you find.

Quote from: tuple on February 15, 2008, 11:54:10 PMThats what we need, helpful players, not more powerful admins.

tehOen


if( up )
{
up[0] = cr * sp * cy + -sr * -sy;
up[1] = cr * sp * sy + -sr * cy;
up[2] = cr * cp;
}

now it is more readable (I would kill myself if I had to read your code)

and for kaleo
printf( "I am" " listening to" " umbrella by " "rihanna." );

/dev/humancontroller

Quote from: Undeferencehttp://www.linuxhq.com/kernel/v1.3/53/Documentation/CodingStyle
Thx. You wouldn't happen to also know the source of the additional readability spaces, would you?func( var qwerty );