Page 1 of 1
Which bracing method do you prefer?
Posted: Tue Jun 08, 2004 11:29 am
by Grim...
a)
Code: Select all
if ($a == 5) {
$b = 5;
} else {
$b = 1;
}
b)
Code: Select all
if ($a == 5)
{
$b = 5;
}
else
{
$b = 1;
}
Posted: Tue Jun 08, 2004 11:29 am
by Grim...
Sorry if this has been done before, but I'm a (b) man, and, of course, that makes me wrong (according to PEAR).
Posted: Tue Jun 08, 2004 11:36 am
by patrikG
It actually has been done before, but I can't find it
I used to do your "b-style", but have defected to "a)" some time ago. It just keeps code cleaner and more space-efficient.
Posted: Tue Jun 08, 2004 11:54 am
by magicrobotmonkey
a all the way. i have some innate "line conserving" instict that I always follow. not sure where it came from...
Posted: Tue Jun 08, 2004 12:58 pm
by feyd
from working with a lot of older coders in my day, the "line conservation" method came mostly from very limited screen space back in the text interface days (like using vim).
Although I, myself, use the second method. To me, it gives more structure, and immediate snap to where the block begins and ends. Part of that may have come from trying to be efficient with my time. Since I've spent the large part of my professional career programming games in a near continuous crunch mode, quickly finding where blocks of code start and stop has taken priority over line efficiency.
Although with any religious faction, there are good points for either side.
Posted: Tue Jun 08, 2004 1:13 pm
by Deemo
i use b, just because it is easier to find the braces later

Posted: Tue Jun 08, 2004 2:05 pm
by Buddha443556
I use a, not to conserve line space though. It's just a perference.
Posted: Tue Jun 08, 2004 6:27 pm
by tim
preference
a is my choice
Posted: Tue Jun 08, 2004 8:02 pm
by PrObLeM
i picked b cause you can see what braces you have closed in complex nesting
Posted: Thu Jun 10, 2004 9:36 pm
by phice
(b) + tabs for any spaces (multiple tabs depending on how far you get into multiple if/else/switch/while/etc).
Posted: Thu Jun 10, 2004 9:44 pm
by feyd
COME ON B!!!

Posted: Fri Jun 11, 2004 3:05 am
by JayBird
a for me
Posted: Fri Jun 11, 2004 7:27 am
by dreamline
I use the b method, since if you have a lot of if then else's it's easier to detect and count the braces...

And believe me the braces can be a jungle at times...

Posted: Fri Jun 11, 2004 10:55 am
by d3ad1ysp0rk
a, but else { is on a new line.
Posted: Sat Jun 12, 2004 5:13 pm
by andre_c
I like a. b makes sense but for some reason I just don't like looking at b. I use a space between the test and the code though