Friday, March 24, 2006

Oh lord - why can't there be a standard for braces?

I hate the way Java folks use the braces in their code. It is so difficult to find matching braces when the opening brace happens to be in the same line as the method declaration or a block scope.

Here is what I'm talking about:

public void foo() {
...
...
...
if (...){
...
...
for (...) {
...
...
} // end of for (...)
...
...
} // end of if (...)
} // end of foo()

Arghhhh!! I hate this. I spent almost few hours trying to find out why a certain brace was matching any open braces. The stupid open brace was sitting snuggly with a for loop in the same line.

I don't care how Java folks program but here is how I'm going to stick to - even in Java programs

public void foo()
{
...
...
...
if (...)
{
...
...
for (...)
{
...
...
} // end of for (...)
...
...
} // end of if (...)
} // end of foo()

Even the context sensitive editors have it built into them for Java files - to give braces as most Java programmers do. Luckily you can change it and I have it changed - in NetBeans IDE. I feel this was mainly adopted as a change that was something different than what C++ folks used to do and Java was first adopted by its fanatics who did not like C++'s way of doing certain elegant things. They just wanted to be different, but for me - its annoying!

0 Comments:

Post a Comment

<< Home