I took a lot of line breaks away to make the post smaller, let me adjust and see if you still agree lol.

I took a lot of line breaks away to make the post smaller, let me adjust and see if you still agree
lol.
;D
It’s like asking a British English speaker (me) to read American English. I mean, it kind of looks like it should make sense, but still ends up feeling like you’re reading gobbledygook.

That’s why skipping the braces is such a bad idea to start with. Down the road you “might” (read: will) need to add statements to that block, and you “might” (read: will) forget to add the braces.
Meh. The notion that coding conventions can prevent bugs is even sillier than test units can.

Meh. The notion that coding conventions can prevent bugs is even sillier than test units can.
I might agree with you, if it weren’t for the sheer number of times I’ve seen bugs caused by forgetting to add braces.
You are both right, IMHO… being allowed to miss braces out of single-line blocks was a huge design flaw that should have been taken out of Java and can lead to some very entertainingly hard to find bugs as @KevinWorkman says - exactly like that - however just having conventions never helps at all because they’re not enforced. You need to have the enforcement automated.
Cas
Not intentionally. Sometimes I forget, but I usually notice it right away.

Never, ever. Eclipse is set to add them automatically if I forget.
This is my preferred method. Just set it and forget it. No question about what is included and what isn’t, and I don’t have to worry about it. I also <3 the setting that automatically places ; and { on the end of the line you’re on.
I never skip braces!
This was very common when I first started programming
At first:
if (blablabla) doStuff();
Yeah, I’m pretty sure I only need to do one thing
5 minutes later… I need to do more stuff on that if, add braces here and there and waste some precious time… FUUUUUUU!
I do always skip them where possible except for nested loops and have never encountered any difficulties while having way less characters in my code that make me slower at reading it.
I always put braces on everything, I’m quite compulsive with this ;D I find it makes the code more readable because its easier to see where the scope starts and finishes among lots of things. I don’t think you lose anything by having them on.
I always put the brace on a new line too, but that’s a whole other discussion!
This leads us into the next holy war. Are you a normal human being and put braces on the same line:
if(isHuman){
System.out.println("I'm a human, not a monster!");
}
Or are you some kind of monster and put braces on the next line:
if(isMonster)
{
System.out.println("GROWL");
}

This leads us into the next holy war. Are you a normal human being and put braces on the same line:
…
Or are you some kind of monster and put braces on the next line:
…
Actually both. I’m using the former way for my home brew stuff and the latter at work. After getting used to both ways, it just doesn’t really matter to me anymore.
[quote]Or are you some kind of monster and put braces on the next line:
[/quote]
Heh that reminds me of my computer science teacher (just taking the class as a formality).
I personally write stuff like this:
public void setValue(String line, String parseable) {
this.line = line;
value = Integer.parseInt(parseable);
}
But my teacher wants this:
public void setValue(String aLine, String parseable)
throws NumberFormatException
{
line = aLine;
value = Integer.parseInt(parseable);
}
I am perfectly fine with either way and believe it is up to the programmer / company, but if I don’t turn it in like the second one, I get it sent back. I also don’t like writing test plans for every single method (even something like .setValue(1) ), but I digress.
There are other things that the teacher forces that I am fine with (ie. documenting each and every method, commenting every variable), but I think forcing the second way upon someone is ridiculous. However, I can’t really argue because in the end, he will only grade it if it is his way (and I want a good grade).

I am perfectly fine with either way and believe it is up to the programmer / company, but if I don’t turn it in like the second one, I get it sent back. I also don’t like writing test plans for every single method (even something like .setValue(1) ), but I digress.
There are other things that the teacher forces that I am fine with (ie. documenting each and every method, commenting every variable), but I think forcing the second way upon someone is ridiculous. However, I can’t really argue because in the end, he will only grade it if it is his way (and I want a good grade).
To be fair, your teacher is doing this for 2 very good reasons:
1- He’s doing it to make grading easier. Imagine grading 30 (or however many students there are in the class) programming assignments, each with their own style, rules about new lines, catching exceptions, etc. That sounds horrible, so to save his sanity (and get your assignments back in a reasonable amount of time), he enforces the same coding conventions on everybody so that he can tell what’s going on just by glancing at the code.
2- He’s doing it to force you to develop good habits. It can be annoying to comment every single section of code and create tests for every single method, but getting into the habit now will be much easier than getting into it after 20 years of coding things your own way.
(of course, if you’ve already been coding things your own way, then yeah, that’s going to be pretty annoying)
There are 13 kids in my class :P, and the problems are quite simple (small objects with a few fields and matching getters/setters) at ~100-150 lines each (24 problems for the semester).
I won’t get into too much detail, but he also grades mine a lot less frequently than other people (even though I turn them in with 5x the frequency), meaning I wait days to find out what I did wrong and then turn the fix in that day and wait until the next day to see how I did.
Also, yeah I have already developed my habits and preferences since June 2013, so it’s not really having an impact on my habits.

This leads us into the next holy war. Are you a normal human being and put braces on the same line:
if(isHuman){ System.out.println("I'm a human, not a monster!"); }
Or are you some kind of monster and put braces on the next line:
if(isMonster) { System.out.println("GROWL"); }
Huh, I guess I’m some sort of hybrid since I do enjoy using both styles
1st for class/method headers, and 2nd for loops/conditions/etc.
public static void main(String[] args) {
if(isHybrid())
{
System.out.println("I'm a hybrid :P");
doOtherCoolStuff();
}
else
{
System.out.println("I guess I'm not a hybrid :(");
doOtherCoolStuff();
}
}
In relation to the post, I only skip adding braces when there is no nesting involved
//I can handle this.
if(notNested()
doStuff();
else
dontDoStuff();
//This makes my brain go numb.
if(nested())
if(stillNesting())
for(int count = 0; count < nestAmount; count++)
for(int dex = 0; dex < nestAmount * 2; dex++)
initMindExplosion(fetalPosition);
void ( i dont get it )
{
in the end it comes down to BSD or ANSI braces style.
http://en.wikipedia.org/wiki/Indent_style
}
they’re all good. nobody cares which one you use. if you’re a good programmer you can read all of them.

//This makes my brain go numb. if(nested()) if(stillNesting()) for(int count = 0; count < nestAmount; count++) for(int dex = 0; dex < nestAmount * 2; dex++) initMindExplosion(fetalPosition);
hehe, I do exactly this, but the following is super evil:
// Some guess-work here ...
if(nested())
if(stillNesting())
for(int count = 0; count < nestAmount; count++)
for(int dex = 0; dex < nestAmount * 2; dex++)
initMindExplosion(fetalPosition);
else
whenWillIdoIt();
Guys. I don’t actually care about where you put your braces. I know it doesn’t matter.
I also know that anybody who puts braces on the next line is a monster.
See also: http://theprofoundprogrammer.com/post/26955601996/text-braces-go-on-the-next-line-you-tremendous
hehe, I do exactly this, but the following is super evil:
// Some guess-work here ... if(nested()) if(stillNesting()) for(int count = 0; count < nestAmount; count++) for(int dex = 0; dex < nestAmount * 2; dex++) initMindExplosion(fetalPosition); else whenWillIdoIt();
Oh lord… I had to throw Holy Water at the screen
// Some guess-work here ...
if(nested())
if(stillNesting())
for(int count = 0; count < nestAmount; count++)
for(int dex = 0; dex < nestAmount * 2; dex++)
initMindExplosion(fetalPosition);
else
whenWillIdoIt();
throw new HolyWaterException;