
52 Replies - 6089 Views - Last Post: 23 September 2013 - 07:07 AM
#1
Why is this a good practice?
Posted 12 August 2013 - 09:47 PM

Replies To: Why is this a good practice?
#2
Re: Why is this a good practice?
Posted 12 August 2013 - 10:07 PM
Some "official" coding standards out there (for instance like Microsoft) encourage programmers to use the left in attempt to make things more "readable" and be consistent with other code they have already written.
But you will find many programmers do either style. Several of us here on DIC actually are "righties" and some are "lefties". But again, it is just a style and a matter of taste. Neither is worse than the other and don't let them tell you any different. You will see both in books too.

This post has been edited by Martyr2: 12 August 2013 - 10:07 PM
#3
Re: Why is this a good practice?
Posted 13 August 2013 - 02:10 AM
I find it more readable. When I look at code, I find it easier to see which brackets belong to which statement when the "right" is used.
#4
Re: Why is this a good practice?
Posted 13 August 2013 - 03:09 AM
Left is Allman, right is K&R.
I prefer Allman, but the quirks of Javascript sort of demand the use of K&R.
#5
Re: Why is this a good practice?
Posted 13 August 2013 - 05:27 AM
I find it easier to read and code looks more compact.
This post has been edited by BlueMelon: 13 August 2013 - 05:27 AM
#6
Re: Why is this a good practice?
Posted 13 August 2013 - 06:08 AM
For languages like ruby with word delimiters, right.
#7
Re: Why is this a good practice?
Posted 13 August 2013 - 07:00 AM
I will use what is required by the project if needed.
Personally I find it more readable, my brain picks up on the bracket symbols a lot better than words. So I see it as an opening rather easily; while still only having to read the first character of a line. Words to me mean variables/constants/etc. It's mainly because of my math background where the alphabet are usually used for the variables and constants, and other symbols for operators.
It's one of my only issues in having to write VB.Net for my job, everything uses english text. So I have to actually READ the damn text to know what's going on, as opposed to just looking for simple symbols. Which is why I prefer C# (as well as C-like languages in general). Coming from a math background is mainly why. Even the functions in math match C-style, where it's alphabet followed by parens with inputs comma delimited:
f(x,y)
This post has been edited by lordofduct: 13 August 2013 - 07:02 AM
#8
Re: Why is this a good practice?
Posted 13 August 2013 - 07:52 AM
[1]Requires citation.
This post has been edited by Switters: 13 August 2013 - 07:53 AM
#9
Re: Why is this a good practice?
Posted 13 August 2013 - 08:25 AM
It's compactness gives it a slight advantage when typesetting books. Since most of us don't write books, it really doesn't matter.
This post has been edited by cfoley: 13 August 2013 - 09:27 AM
#10
Re: Why is this a good practice?
Posted 13 August 2013 - 09:22 AM
But there is no right or wrong here.
K&R gives compact code but the Allman style makes the code easier to follow (or it should but it's not available for everybody) since all brackets are on the same "column" so you will always new the closing bracket is somewhere straight below.
Also, you shouldn't worry much about this since most editors offer the possibility to set the style you like, no matter how others code.
#11
Re: Why is this a good practice?
Posted 13 August 2013 - 09:26 AM
Quote
I think whichever you are used to is easier to follow.
#12
Re: Why is this a good practice?
Posted 13 August 2013 - 09:29 AM
#13
Re: Why is this a good practice?
Posted 13 August 2013 - 01:06 PM
#14
Re: Why is this a good practice?
Posted 13 August 2013 - 01:47 PM


But, again, just an opinion

This post has been edited by andrewsw: 13 August 2013 - 01:52 PM
#15
Re: Why is this a good practice?
Posted 13 August 2013 - 01:53 PM