The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Brace yourself

Posted by Matt Gerrans on November 22, 2001 at 3:10 PM

> Guess that makes it 2-2.

> Also, having the opening brace on the same line as the associated line of code takes up less lines. But before you all flame me, no I dont code "command1; command2; command3;" on one line :-). I just think it looks neater.

> JMHO, though

> Jody

Yes, I think it is mostly based on what you learned first. Whatever that was will seem natural.

When I first learned to program on Windows, Petzold's Programming Windows 3.1 was the main reference. I also learned whole Hungarian notation (where you decorate variable name to death with type information) and it seemed normal for many years. It took me a while to unlearn that habbit, but now, it seems so clear to me what a bad idea Hungarian Notation is. Same thing with curlies. I originally learned the more common

void foo( blah ) {

way, but later realized that the

void foo( blah )


placement actually has more rational arguments to support it (automatically adds whitespace to your code, making methods easier to find, lines up braces, making scopes easier to see).

It is mostly a subjective thing, so it is a good thing code-formatters are abundant.

One of the things I love about the Python programming language is that there are no curly braces at all. Guido was smart enough to realize that they are not even needed.

- mfg


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us