[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

What curly brace style do you use?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 13
Thread images: 2

File: allmanstyle.jpg (18KB, 489x291px) Image search: [Google]
allmanstyle.jpg
18KB, 489x291px
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 like
void sayHello() {
std::cout << "Hello, World!\n";
}


when collapsed it shows as
void sayHello () { 


but, if I use Allman style, it instead collapses as

void 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 one

int
main(int argc, char *argv[])
{
if(expression) {
//stuff
// other stuff
} else {
// stuff
// other stuff
}

return 0;
}
>>
One True Brace Style
>>
File: 1459711372273.png (230KB, 640x360px) Image search: [Google]
1459711372273.png
230KB, 640x360px
>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 use
void 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 do
public void doStuffWithThese(
int someNumber,
String text,
float iceCreamAndRootBeer,
Object loo)
{
return;
}
>>
>>55881857
K&R style, all day.
Thread posts: 13
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

If you need a post removed click on it's [Report] button and follow the instruction.
If you like this website please support us by donating with Bitcoin at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties. Posts and uploaded images are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that website. If you need information about a Poster - contact 4chan. This project is not affiliated in any way with 4chan.