I prefer K&R style (your original style). I use one liners (without braces) only when testing something and prefer to not have them in real code.
My problem with Astyle is that actions are visually separated from condition (braces are thin and easy to overlook). How I see Astyle code at first glance:
I guess its a matter of taste. Like how some people prefer putting spaces in between the parentheses and the condition while others don't like spaces at all, or your '*' placement, or your cv-qualifier placement, etc. Personally, I think the only thing that matters is consistency of style.
if (condition1) action1;
elseif(condition2) action2;
else action3;
// OR
if(condition){
action1;
}else{
action2;
}
// OR
if(condition){
action1;
}
else{
action2;
}
// I usually try to use this one when helping with someone else's code
if(condition)
{
action1;
}
else
{
action2;
}
@Little Bobby Tables
Different programming languages have different styles that are associated with them. As a general rule, C is assumed to have a coding style like this:
1 2 3 4 5 6 7 8
if (something)
{
dosomething;
}
else
{
dosomethingelse;
}
While Java traditionally is layed out similar to how my code and @NoXzema's code was layed out. Don't ask me why, I don't actually know.