Which bracing method do you prefer?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply

Which bracing method do you prefer?

a
11
58%
b
8
42%
 
Total votes: 19

Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Which bracing method do you prefer?

Post 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;
}
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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).
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

a all the way. i have some innate "line conserving" instict that I always follow. not sure where it came from...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

i use b, just because it is easier to find the braces later 8O
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

I use a, not to conserve line space though. It's just a perference.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

preference

a is my choice
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

i picked b cause you can see what braces you have closed in complex nesting
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

(b) + tabs for any spaces (multiple tabs depending on how far you get into multiple if/else/switch/while/etc).
Image Image
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

COME ON B!!! :P
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

a for me
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post 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... :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

a, but else { is on a new line.
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post 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
Post Reply