Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.

View Poll Results: Which do you prefer?

Voters
22. You may not vote on this poll
  • Number 1

    12 54.55%
  • Number 2

    10 45.45%
Results 1 to 15 of 15
  1. #1
    Regular Coder BrickInTheWall's Avatar
    Join Date
    Mar 2009
    Location
    Munich, Germany
    Posts
    139
    Thanks
    1
    Thanked 13 Times in 13 Posts

    So which do you prefer...

    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:
    Code:
    void functionName( void ){
    // bla
    }
    or Style 2:

    Code:
    void functionName( void )
    {
    // bla
    }
    I prefer number 1

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,728
    Thanks
    6
    Thanked 1,015 Times in 988 Posts
    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).

  • #3
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Definitely #2 - for the reasons mentions by VIPStephan
    John

  • #4
    Senior Coder
    Join Date
    Oct 2005
    Posts
    1,340
    Thanks
    0
    Thanked 61 Times in 60 Posts
    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.
    Last edited by drhowarddrfine; 07-03-2009 at 09:41 PM.

  • #5
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    I prefer No. 2 for the same reasons given by VIPStephan.

    effpeetee
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Quote Originally Posted by drhowarddrfine View Post
    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++.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    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.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    #2.
    Easier to identify starting blocks while adhering to an 80 char max line length wrap.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #9
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by drhowarddrfine View Post
    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

  • #10
    Senior Coder
    Join Date
    Oct 2005
    Posts
    1,340
    Thanks
    0
    Thanked 61 Times in 60 Posts
    Quote Originally Posted by oesxyl View Post
    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.

  • #11
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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

  • #12
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    I use both of them frequently... #1 for more compact code, #2 for readability... and I voted for #2...

  • #13
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    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).........

  • #14
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by abduraooft View Post
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #15
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I prefer number 2. It just looks more clean for me!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •