Poll

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

Author Topic: What indentation style do you prefer?  (Read 9760 times)

/dev/humancontroller

  • Posts: 1033
  • Turrets: +1002/-383
What indentation style do you prefer?
« on: July 12, 2007, 06:14:14 am »
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

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
What indentation style do you prefer?
« Reply #1 on: July 12, 2007, 11:59:09 am »
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

  • Guest
What indentation style do you prefer?
« Reply #2 on: July 12, 2007, 12:01:35 pm »
indentation is for the losers I code everything in 1 line

benmachine

  • Posts: 915
  • Turrets: +99/-76
    • ben's machinery
What indentation style do you prefer?
« Reply #3 on: July 12, 2007, 12:58:52 pm »
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

  • Tremulous Developers
  • *
  • Posts: 554
  • Turrets: +302/-7
    • Ingar's projects on the Web
What indentation style do you prefer?
« Reply #4 on: July 12, 2007, 04:21:09 pm »
Indentation is for code beautifiers
http://astyle.sourceforge.net/

I use tabs myself.

/dev/humancontroller

  • Posts: 1033
  • Turrets: +1002/-383
What indentation style do you prefer?
« Reply #5 on: July 12, 2007, 05:12:36 pm »
Quote from: "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.

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

  • Posts: 1033
  • Turrets: +1002/-383
What indentation style do you prefer?
« Reply #6 on: July 12, 2007, 05:14:06 pm »
Quote from: "Ingar"
Indentation is for code beautifiers
http://astyle.sourceforge.net/

I use tabs myself.

Sample result code plz?

Ingar

  • Tremulous Developers
  • *
  • Posts: 554
  • Turrets: +302/-7
    • Ingar's projects on the Web
What indentation style do you prefer?
« Reply #7 on: July 12, 2007, 05:55:04 pm »
Quote from: "/dev/humancontroller"

Sample result code plz?


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

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

David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
What indentation style do you prefer?
« Reply #8 on: July 12, 2007, 05:56:46 pm »
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

  • Guest
What indentation style do you prefer?
« Reply #9 on: July 12, 2007, 06:40:37 pm »
omg formatting doesnt matter as long as it is readable
it is just a convention
btw ansi FTW

/dev/humancontroller

  • Posts: 1033
  • Turrets: +1002/-383
What indentation style do you prefer?
« Reply #10 on: July 13, 2007, 12:51:22 pm »
Quote from: "David"
I 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:
Code: [Select]
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.
Code: [Select]
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

  • Posts: 2098
  • Turrets: +176/-220
    • KaleoDesign
What indentation style do you prefer?
« Reply #11 on: July 13, 2007, 03:14:38 pm »
2. Or 3 sometimes.
Code: [Select]
//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

  • Tremulous Developers
  • *
  • Posts: 1254
  • Turrets: +122/-45
Need help? Ask intelligently. Please share solutions you find.

Thats what we need, helpful players, not more powerful admins.

tehOen

  • Guest
What indentation style do you prefer?
« Reply #13 on: July 13, 2007, 10:39:49 pm »
Code: [Select]

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

  • Posts: 1033
  • Turrets: +1002/-383
What indentation style do you prefer?
« Reply #14 on: July 13, 2007, 10:53:52 pm »
Quote from: "Undeference"
http://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?
Code: [Select]
func( var qwerty );