Why is this a good practice?

  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4

52 Replies - 4677 Views - Last Post: 23 September 2013 - 07:07 AM

#46 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Why is this a good practice?

Posted 15 August 2013 - 04:22 PM

Steve McConnel covers this in chapter 31 of Code Complete, 2nd edition. Conclusion?
... you might simply choose the style you like or the one that is preferred by the majority of people on your team. Either pure-block emulation or begin-end block boundaries work equally well. The only study that has compared the two styles found no statistically significant difference between the two as far as understandability is concerned (Hansen and Yim 1987).

Was This Post Helpful? 0
  • +
  • -

#47 depricated  Icon User is online

  • Derpicorn

Reputation: 754
  • View blog
  • Posts: 2,503
  • Joined: 13-September 08

Re: Why is this a good practice?

Posted 16 August 2013 - 01:43 PM

View Poststephen.d, on 15 August 2013 - 11:28 AM, said:

The left is just a little easier for newbies to read. Visually lining up the braces in:


can confirm

source: I'm a newbie
Was This Post Helpful? 2
  • +
  • -

#48 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2021
  • View blog
  • Posts: 4,194
  • Joined: 11-December 07

Re: Why is this a good practice?

Posted 16 August 2013 - 03:26 PM

View Postdepricated, on 16 August 2013 - 09:43 PM, said:

View Poststephen.d, on 15 August 2013 - 11:28 AM, said:

The left is just a little easier for newbies a newbie to read. Visually lining up the braces in:


can confirm

source: I'm a newbie


Fixed that for you. ;)

You make a good point though. I haven't read that one study that was done on the subject. I bet it has a sample bias though.
Was This Post Helpful? 0
  • +
  • -

#49 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 849
  • View blog
  • Posts: 2,585
  • Joined: 29-July 11

Re: Why is this a good practice?

Posted 18 August 2013 - 09:14 PM

Not to beat a dead horse, but it's best for everyone, especially other people who read your code, when you follow the style in you language's coding conventions.
Was This Post Helpful? 1
  • +
  • -

#50 LawlessBaron  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 115
  • Joined: 07-February 13

Re: Why is this a good practice?

Posted 19 August 2013 - 07:34 PM

i use the left one in everyday coding and the right one in Java but i prefer the left one
Was This Post Helpful? 0
  • +
  • -

#51 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Why is this a good practice?

Posted 30 August 2013 - 11:07 PM

View PostSwitters, on 13 August 2013 - 09:52 AM, said:

I'm a leftie. Don't listen to anyone who argues for the style on the right. Studies have shown that 98% of people who prefer the K&R indentation style were dropped frequently as children and have a high tendency towards deviant behavior.[1]

[1]Requires citation.

You must put the toilet paper on the outside...

I use the left convention in CSS files and the right in everything else. Don't know why.
Was This Post Helpful? 0
  • +
  • -

#52 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7807
  • View blog
  • Posts: 13,203
  • Joined: 19-March 11

Re: Why is this a good practice?

Posted 30 August 2013 - 11:09 PM

View PostBobRodes, on 31 August 2013 - 01:07 AM, said:

You must put the toilet paper on the outside...



What if it rains?
Was This Post Helpful? 0
  • +
  • -

#53 NecroWinter  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 320
  • Joined: 21-October 11

Re: Why is this a good practice?

Posted 23 September 2013 - 07:07 AM

I prefer right, as for readability, I try to put a short comment after the } to indicate what it closes. So for example:



if (x==2){
//code

}//end if x==2



Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4