• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Do you use brackets?

If they're required. I don't usually use them for one-line blocks.
if(condition)
{
somefunction()
}
else
{
otherfunction()
}

Just seems to waste so much damn space.
 
If you're writing code professionally, you should always use them, even for single-line blocks. It is more readable and will cut down on future mistakes.

I prefer put the open brace on the same line as the if/while/else/etc though to cut down on space used.

if( blah == 1 ){
burp();
}
 
Not in Python =)

But most of the time I don't skip them even for one-liners in Java. With NetBeans I only have to type one of 'em most of the time, the stuff's all indented right too. If not, highlight a bunch of stuff and press CTRL + SHIFT + F.
 
Originally posted by: ArmchairAthlete
Not in Python =)
I added the last line for you 😉😛
But most of the time I don't skip them even for one-liners in Java. With NetBeans I only have to type one of 'em most of the time, the stuff's all indented right too. If not, highlight a bunch of stuff and press CTRL + SHIFT + F.

Wow, that's pretty cool.
 
If I don't the code formatter does it for me so there isn't much choice.
At any rate, all I have to do it type:
if (condition) { <return>

and this is automatically generated:

if (condition) {
...|
}

where the pipe is the location of the cursor so it's not actually much extra typing.

Edit: I think you should add some more options to the second poll. I can live with one liners but if you put the statement on a second line and indent it then I'd much rather see some brackets.
 
For one-line statements? No, although I indent the statement. I don't think it's hard to read if it's indented.
 
Sometimes I'm of the thought that "this could grow, and it would be less likely to create a problem if you just toss braces around it. Late at night with little to no sleep, I can and do make such stupid mistakes once in a while. Then again, I shouldn't be coding that late anyhow.

What I really dislike is the one liners
eg if (something) blah();

I'd much rather see
if (something)
blah();

Don't know why. Just preference for one reason or another.
 
I always write as little code as possible so I only use them when it's absolutely necessary. I'd much rather indent or better yet, leave it on the same line. Vertical screen estate is precious, especially when scolling through pages and pages of code.

 
I had to track down a bug once and came across code something like this

if foo if bar x=something;

The problem was foo and bar were not boolean values.
 
Back
Top