To me, placing the opening curly brace on the same line as the function statement is just a little more elegant and poetic. I see
function someFunction(){
...
}
as much like
Once upon a time
...
The End
The opening curly brace is part of an opening statement. Putting the curly brace on the next line seems a little like putting a period on the next line after the end of a sentence.
When working with a body of code that already exists, I don't have any problem conforming to it's style. But when I have the freedom to set my own style, I certainly prefer the curly brace on the same line.

7 comments:
You are so WRONG! Only idiots do it that way!
:) just kidding.
I prefer the brace on the next line, but I've flip-flopped on it over the years. I see it like:
function someFunction()
{
...
}
is like:
Chapter 1
blah blah blah
...
end blah
Hahaha! I knew you couldn't leave that post alone, Keith ;-)
I guess I don't think of functions as being chapters, since a chapter seems like too long. I like to keep my functions short, like a short story :-) If a function starts getting too long, I start looking for better ways to encapsulate.
You guys are both wrong! You should keep all code on the same line. :P
function someFunction(){ ... }
Seriously, I'm surprised that you opened this giant can of worms! :)
I'm with you Kristin. I've been meaning to write a little AIR utility for CORRECTING code that I copy that uses the WRONG format! :)
i am a fan of the curly braces on their own line... i think it makes the code a bit easier to read. I don't really understand how see putting the brace on it's own line is like putting a period on the line after a sentence because the opening curly brace is not the end of the function, it doesn't correspond to a period =)
ha! ok...let's say that it's like putting a semi-colon on the next line :-)
I'm really curious. How does having the curly brace on the next line make it more readable? Does it help you visually organize the code?
semi colon works =)
perhaps the code isn't more readable, but i feel like it is organized better. The curly brace being on its own line makes it really easy to see where matching closing braces are, easy to spot the function declaration or conditionals. It all boils down to personal preference obviously, but i always feel like the code is easier to go through especially if looking at code you didn't write.
Post a Comment