Java/C#/C++/[insert language here] brackets

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

EyeMWing

Banned
Jun 13, 2003
15,670
1
0
Originally posted by: Auryg
2...just looks..cleaner.

Yeah, whenever I see code done with the bracket on the same line, I'm like "WTF kind of dirty linux user did this?"
 

tami

Lifer
Nov 14, 2004
11,588
3
81
i prefer method 2, but i don't program in any such languages anymore. i like aligned brackets -- easier to find its start and finish.
 

Jumpem

Lifer
Sep 21, 2000
10,757
3
81
Method 2 is what I always preffered. At work the software standards manual specifies 2 as well.
 

Originally posted by: EyeMWing
Originally posted by: Auryg
2...just looks..cleaner.

Yeah, whenever I see code done with the bracket on the same line, I'm like "WTF kind of dirty linux user did this?"

haha, man...i should show some of the code that our sys admin wrote one day
 

#1 is the K&R style

if(true) {
...
}

#2 is the Berkeley (BSD) style

if(true)
{
...
}

IMO, #2 is MUCH cleaner.
 

JustAnAverageGuy

Diamond Member
Aug 1, 2003
9,057
0
76
if (x)
{

<indent>code here;

<indent><indent> {
<indent><indent><indent> code here;
<indent><indent><indent> code here;
<indent><indent> } while (y);

<indent> code here;

}

Like this :)
 

Syran

Golden Member
Dec 4, 2000
1,493
0
76
Originally posted by: JustAnAverageGuy
if (x)
{

<indent>code here;

<indent><indent> {
<indent><indent><indent> code here;
<indent><indent><indent> code here;
<indent><indent> } while (y);

<indent> code here;

}

Like this :)


/Agree.

#2 w/ indentions here for me.
 

PricklyPete

Lifer
Sep 17, 2002
14,582
162
106
Originally posted by: dighn
2 for me. I'm just used to it because Visual Studio defaults to that style.

I don't remember exactly when I started...but that might have been the reason for me as well.