Untitled

...

>9GAG

Use the style recommended by whatever project you are working on.
Use the style you prefer when working on your own projects.

>9gag

don't you mean 10 types of people?

Lol ecksdee. It's easy as 1 10 11

HAHAHA HE MADE THAT JOKE AGAIN :D

>If programming languages were X

New line for JavaScript. Same line for everything else.

>4/4

This is why everyone hates JS except developers that only know JS

what about

if (Condition) {
Statements
/*
...
*/}

>triggered

Plebs

>not a programmer
>still know

LOCK ME UP

>putting space between "if" and opening parenthesis
cancer

>when you like python for all the wrong reasons

static void Main(string[] args)
{
int = 5 ;
int = 5 ;
bool = false ;

if ( = )
{
= true ;
}

Code tags evidently do not support my emoji variables

Cancer

truly nothing better

THIS.
honestly took me years to fully accept this. I used to enforce my own style in every language and every project I worked on. Now I finally started following the style guide for the specific language I'm working with because i wouldn't want some random person to write ruby style in my java code, etc

It's cool, you seem like a faggot either way.

Commit suicide

The cleanest style:

if (condition)
/* Single statement */

if (condition) {
/* Multiple statements go here */
}

if (condition) {
/* Single or multiple statements */
} else {
/* Multiple statements */
}

void function()
{
/* Anything goes here */
}

at least please be consistent, please use the same brackets for functions. thank you

This is a neat way to enforce a 80 chars limit, but the benefit of parenthesis are a very clear way to describe encapsulation of scope.
While there will always be someone who thinks this is a "issue" (even though the majority agrees on B for if, for and while statements and A for functions), it is not an issue because there will always be a rule of law when it comes to this: The coding standard.
If you can't follow a coding standard when contributing to a project, you need to get the fuck out.
If you can't mentally handle that someone uses a different standard than what you would prefer, then you are a bad programmer.
The same goes for standards regarding whitespace/indentation width, which parts should be indented etc.
Ideally we would have a "coding standard standard" which would be an easy and concise way to describe how the code should be formatted which automatically could be picked up by checkers.
There might be a solution like this, but I am not aware of this.
The same tool could even generate an estimate given an existing project.

There is no reason to use brackets for a single statement just because you have an else.

depending on the language... one of those won't compile

That's pretty much the state of these days

close, but the first one will lead to bugs guaranteed.
t. professional programmer that has seen many bugs due to leaving out braces for single line if statements

if you're really anal about it being a one-liner, try to turn it into a ternary instead

It may not be important in C, but in C++, it makes a lot of sense to use braces on a separate line for functions.
Take this example of a class constructor:
example::example() :
val(0.1),
ptr(new other_class(val))
{
ptr->some_function();
}

It is easier to read when you do it this way.
Furthermore, it makes it easy to copy paste to your class declaration.

If statements on the other hand will be written several times over and saving space is a better as the statements and the conditions are closely linked.
I often do
if (condition) statement;

when there is multiple tests to be made as it aligns better.
if (condition) statement;
if (condition) statement;
if (condition) statement;
if (condition) statement;

ah yes i do agree in that instance when u have initialization lists it is more elegant to have each on a separate line, sorry.
also the simple inline ifs are also quite elegant i agree.

I never really thought that it also solves the problem states, I just thought it was more readable.
But I guess this is a reason as well.
I basically judge it case by case, some times it is more readable to use braces even if there is just a single argument.
I guess I am not that consistent when I write my own projects

Left is correct.
Right breaks as soon as you need an initializer list.

i'm not a programmer and i get it you stupid sack of faggot nigger shit with down syndrome

K&R can never be wrong you degenerate

There should be one kind of people, the one that stick to the fucking project guidelines.

/*
* ...
*/

This

>using code formatter

>} else {
wrong

Im the one on the right
tend to be alot more compact than that though, much more compact
> multiple statements per line

What's the idea behind this? Are they trying to make C++ (or whatever language that is) look like Python?

fuck I love how compartmentalized this is... I may start doing this

Either is fine as long as you don't cuddle your else statements

>baited

almost correct but the function definition is wrong

int
main(int argc, char *argv[])
{
if(condition)
do_stuff();

if(multi_line) {
do_stuff();
other_stuff();
} else {
do_stuff();
other_stuff();
}

return 0;
}

I personally don't like putting the type specifier on its own line but I do put a storage class specifier on its own line.

I also greatly dislike "array" parameters in C.

autism

It's Java. learn your languages!

I use this
if (cont) {func1;
func2;}

Left is for functions, right is for conditions/loops
This is standard pretty much everywhere

>capital letters

go back to python retard

>There are two types of people.
No, there are a lot more than that.
See
and

>Not knowing about K&R.

ew

i'm accustomed to assembler so everything i write follows that format

>no bracket if
It's like you want Pajeet to come in, break your code, then blame you for later. Always add the brackets; it's four god damn characters including the newline characters and it prevents so many issues later.

fucking hell came here to post this desu, this should be bannable where the fuck is moot