Source Code Indentation / Style

stevenh

User avatar

Sticking around

Posts: 28

Joined: Sat Mar 15, 2008 4:48 am

Location: Canberra, Australia

Post Thu Mar 20, 2008 9:30 am

Source Code Indentation / Style

To all... now that we have end-of-line characters sorted to CRLF, can we please standardise the tabbing/indentation.

My preference is to actually use TAB characters for the Source code, but that's only me... it then allows me to set my environments up to have proper tab-spacing and autocompletion...

Any objections? I intend on saving any further source to this standard and will eventually update it all and conquer the world.

jendave

Sticking around

Posts: 32

Joined: Fri Mar 14, 2008 7:53 pm

Post Thu Mar 20, 2008 3:28 pm

Re: Source Code Indentation

Note that the MS standard (i.e. what VS 2005 does when you auto-reformat the file) uses spaces and not tabs.

freegamer

User avatar

Site Admin

Posts: 119

Joined: Fri Mar 14, 2008 3:11 pm

Post Thu Mar 20, 2008 3:51 pm

Re: Source Code Indentation

Indeed I know a lot of people who object to using tabs, but tbh it's up to the people working on the code so I'll not state a preference one way or the other. (As long as everybody uses the same and only the same for indentation in the code, it's a bit of a non-issue.)
Free Gamer - open source games blog
FreeGameDev forums - open source games development community

freegamer

User avatar

Site Admin

Posts: 119

Joined: Fri Mar 14, 2008 3:11 pm

Post Wed Mar 26, 2008 8:31 pm

Re: Source Code Indentation

Another issue related to indentation - how to handle braces?

The current style consumes a lot of vertical space:
  Code:
try
{
    this = foo;
}
catch(Exception e)
{
    System.Console.Out.WriteLine("problem!");
}

I personally prefer this which makes code easier [for me] to read, in bulk and as blocks:
  Code:
try {
    this = foo;
} catch(Exception e) {
    System.Console.Out.WriteLine("problem!");
}
Free Gamer - open source games blog
FreeGameDev forums - open source games development community

stevenh

User avatar

Sticking around

Posts: 28

Joined: Sat Mar 15, 2008 4:48 am

Location: Canberra, Australia

Post Wed Mar 26, 2008 9:53 pm

Re: Source Code Indentation / Style

Charles,
I remember back in the day when learning Human-Computer Interaction as a subject at uni that your preferred method (and it's also my preferred method) although looking much neater is "not as easy to follow" as the "standard" method that we have now adopted in the codebase.

When I write things by myself I definately use the much compacter method of braces/etc inline but in this case it's safest to use the fully-expanded method when writing something that multitudes (here's hoping) of people will look at and attempt to understand.

As for tabs and spaces... I love tabs and hate spaces... I understand Microsoft loves spaces... but I hate them, so it's a lose-lose situation...
Anyway, since it'd be a complete overhaul of every line of code, I'll survive with using that nasty space character.

freegamer

User avatar

Site Admin

Posts: 119

Joined: Fri Mar 14, 2008 3:11 pm

Post Wed Mar 26, 2008 9:58 pm

Re: Source Code Indentation / Style

Most good editors should handle the tab/spacing issue you.

For MonoDevelop, it's in Preferences->Text Editor->Behaviour and "Convert tabs to spaces".
Free Gamer - open source games blog
FreeGameDev forums - open source games development community

Return to Core Development

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.