...

View Full Version : So which do you prefer...



BrickInTheWall
07-03-2009, 12:53 AM
This may seem extremely silly but I've seen code blocks written in either style very often and would like to know which one you prefer...(look at the brackets)

Style 1:


void functionName( void ){
// bla
}


or Style 2:



void functionName( void )
{
// bla
}


I prefer number 1

VIPStephan
07-03-2009, 02:27 AM
Me too. But I’ve read somewhere that in the second version you can see more easily where a curly bracket section starts and ends (or which brackets belong to each other, respectively).

PappaJohn
07-03-2009, 02:45 AM
Definitely #2 - for the reasons mentions by VIPStephan

drhowarddrfine
07-03-2009, 03:28 AM
Some time ago I switched to #2 because that's the FreeBSD coding style and that's what I use. That's for functions only. Loops put the first brace on the same line.

effpeetee
07-03-2009, 01:47 PM
I prefer No. 2 for the same reasons given by VIPStephan.

effpeetee

abduraooft
07-03-2009, 02:35 PM
Some time ago I switced to #2 because that's the FreeBSD coding style and that's what I use.
I've switched to #1, as it's easier to view more code in a single window without those extra line break on each block. To match the curly braces, I use notepad++. :)

ckeyrouz
07-03-2009, 05:29 PM
The number is much clearer and much easy to see where the blocks loop inside other blocks.

You should try it with a 19 Inches screen and plus.:)

Fou-Lu
07-03-2009, 09:05 PM
#2.
Easier to identify starting blocks while adhering to an 80 char max line length wrap.

oesxyl
07-04-2009, 04:50 AM
Some time ago I switched to #2 because that's the FreeBSD coding style and that's what I use. That's for functions only. Loops put the first brace on the same line.
really? or is just a opinion? :)

I use #1 and I really hate #2, :)

best regards

drhowarddrfine
07-04-2009, 05:31 AM
really? or is just a opinion? :)

I use #1 and I really hate #2, :)

best regards

Yeah. It's published in the style guide so it must be opinion.:rolleyes:

oesxyl
07-04-2009, 07:15 AM
I don't think that style is important for somebody else then ourself for few reasons:
- if a project is a team project doesn't matter what you prefere, you must commit the sources with same style like everybody else. That if you are not the main contributor and you force everybody to use your prefered style, :) but this is pretty unpolite imo
- is easy to change from one style to another using some tools like fmt or/and some simple scripting, I use awk, sed, bash usualy and perl, tcl if things become complicate.
- any decent editor can be easy configured to work as you want with any style you like

Imagine somebody who indent code using both tabs and spaces with tabstops to 8. I use tabstobs at 3 and I guess is not hard to understand why I hate #2, :)
is not realy a problem but sometime is annoying, :)

best regards

kokjj87
07-04-2009, 12:27 PM
I use both of them frequently... #1 for more compact code, #2 for readability... and I voted for #2...

Brandoe85
07-06-2009, 06:16 PM
Definitely and always #2, I can't stand #1...and don't get me started when I see #1 and underscores(aside from private member variables).........:cool:

_Aerospace_Eng_
07-06-2009, 08:51 PM
I've switched to #1, as it's easier to view more code in a single window without those extra line break on each block. To match the curly braces, I use notepad++. :)

DW in code view allows you to collapse blocks of code so you can see more code in a single window.

awarehost
07-08-2009, 06:08 AM
I prefer number 2. It just looks more clean for me!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum