By daveschinkel
via codezest.com
Published: Dec 09 2008 / 12:22
![]() | |
| HTML5 Canvas | |
| Written by: Simon Sarris | |
| Featured Refcardz: Top Refcardz: | |
| 150+ Refcardz Available · Get them all | |
By daveschinkel
via codezest.com
Published: Dec 09 2008 / 12:22
Comments
willcode4beer replied ago:
1 & 3 I agree strongly with.
#2 I could care less, as long as placement is consistent with the entire group.
I voted down because this looks like the start of a pointless curlybrace war, and I'm sick of 'em
mostlyharmless replied ago:
coding standards say... same line
http://java.sun.com/docs/codeconv/html/CodeConventions.doc5.html
Read more about industry standards at
http://www.dzone.com/links/software_development_standards.html
And I know those are java standards not javascript, but if I am working in a java shop, then we're going to follow through, especially since javascript does not have established industry standards.
senfo replied ago:
Java coding standards have always put the curly braces on the same line. I've always disagreed with that format. Luckily, C# coding standards place the curly brace on the next line.
Actually, come to think of it, Java and JavaScript are the only two languages that I know of where it's preferred that you place the curly brace on the same line. Coding standards for C, C++ and C# all say to put it on the next line.
mostlyharmless replied ago:
That's fair. The point is that there are established standards for your languages and that you follow them and no makup your own for arbitrary, and subjective reasons.
dragmire replied ago:
Does it really matter what Sun/Java says?
Put the curly wherever it looks good for your team. Don't rely on the "industry standard" for defining where the damn curly goes.
jkirstein replied ago:
rubbish
amphi replied ago:
http://en.wikipedia.org/wiki/Indent_style
I started with Whitesmiths style, then switched to Allman/BSD style, and finally to K&R 1TBS aka hugging brackets. I don't put brackets around single line conditionals though, since that *never* has been a source of errors for me. I also omit all those fluff spaces unless there is a comma. Additionally, I add empty lines here and there to break up bigger code chunks into separate logical blocks (e.g. AAAA B CC DDD - where A/B/D are methods of individual objects and C is an if+method call). If necessary I'll also prefix those blocks with a comment. (Well, that's my private style. Of course I do use the company's/project's style if there is any. It's easy enough with auto formatting. ;))
I used each of these 3 styles for a few years and in my experience it doesn't matter at all which one you're using. Each one offers enough visual hooks.
noahz replied ago:
Why is this on the front page? Don't we have better things to think about than curly-brace religious wars?
eric32 replied ago:
Maybe we should all write hungarian notation too!
eelmore replied ago:
You argue that long methods are unequivocally bad. Then, you argue that people should waste lines of code with braces that stand on a line by themselves. This argument against the One-True-Brace-Style is worse than most....
Voters For This Link (7)
Voters Against This Link (22)