I use the allman style. I don't see a lot of people using it for java or javascript. I like it because it puts the opening and closing braces on the same level and spaces everything out. It's just easier for me to read and see where the braces lie.
A lot of people I know use the ratliff style. I find it harder to read.
Here's a wikipedia article on the styles:
https://en.wikipedia.org/wiki/Indent_style
>>55881857
I use "Java style" (i.e. opening brace on the same line as the conditional/loop statement or function/struct/class declaration, closing brace on its own line after the body of the block). I find Allman style more aesthetic in some ways, but the way code collapsing works in my ide, it hides all lines AFTER the opening brace up to the closing brace.
So if I write a function likevoid sayHello() {
std::cout << "Hello, World!\n";
}
when collapsed it shows asvoid sayHello () {
but, if I use Allman style, it instead collapses asvoid sayHello()
{
which I think looks silly.
>>55881857
i like the GNU style
but I only use it for my personal stuff
>>55881857
>I don't see a lot of people using it for java or javascript.
Because it doesn't work in JavaScript, thanks to the retarded semicolon insertion for retards.
>>55881857
Same, I tend to stick with Allman style for the sake of readability, but I might switch to Stroustrup's K&R adaptation now.
>>55881857
https://www.kernel.org/doc/Documentation/CodingStyle
Chapter 1
>>55881857
>work at a software company as a programmer
>everything is written in C#
>use curly braces as the pic here >>55881857
>this is recommended by Microsoft and enforced by Visual Studio
>new back end dev is hired
>he starts working on one of the existing back end services
>one day one of the other backenders waves me over
>I walk over to him and he points at the screen
>"take a look here, this is what the new backender has written even though I have spent several hours going over our programming style with him"
>(just a note, the backender who showed me this also happens to be the lead dev)
>new programmer use Java style curly braces splattered all over the original code
>writes IF sentences without curly braces
>even writes entire functions as one liners just because
>writes useless abstraction after abstraction
This really grinds my gears.
>>55881857
> What curly brace style do you use?
the best oneint
main(int argc, char *argv[])
{
if(expression) {
//stuff
// other stuff
} else {
// stuff
// other stuff
}
return 0;
}
One True Brace Style
>GNU Style
The whole GNU C Library looks like this and it's the most unreadable garbage I've ever seen. This is Richard Stallman's worst contribution to humanity.
>>55881857
Whatever clang-format spits out by default.
>>55881857
usually I usevoid foo()
{
//stuff here
}
but in java I generally stick to the java way, unless I'm writing a function with so many parameters that they don't fit into the line width of the project (80 characters for what I'm currently working at) in which case i dopublic void doStuffWithThese(
int someNumber,
String text,
float iceCreamAndRootBeer,
Object loo)
{
return;
}
>>55881857
K&R style, all day.