You know you're the spawn of Lucifer if...
>>62195990
... you don't follow the code standards guides for your project, language or framework
>>62196136
/thread
>>62195990
>if (
eww
>>62195990
>You know you're the spawn of Lucifer if...
You put all your braces 15 tab stops across.
>>62196237
>if
>{
eww
You know you're not a programmer who actually programs but a retarded g poster when the only topics you can contribute to are these retarded bikeshedding topics.
>>62196136
fpbp
>>62195990
I know this is bait, but for anyone who does this get a bunch of sequential if statements and fold the code.
condition
condition
condition
looks better than:
condition
{
condition
{
condition
{
OTBS is love, 1TBS is life.
if (
condition ){
}
>>62199164
this
>>62199164
>>62199183
i never hoped that much it's samefagging
>>62199246
>>62195990
You tell a compiler a way to construct a block statement?
I see this as an effective way to simply indentation and messy coding habits. May improve performance though I have yet to read that deep into Java.
>>62199128
My man you are reminding me of Switch and case statements.
I guess switch and case statements are a way to promise it will do something compared to checking if a condition is met through the if.
>>62199246
Never have I knew that /g/tards try and guess the man behind the anon
Memes a hoe
>>62199164
what the fuck
>>62199352
if (condition ); int i == 0 || int j == i;[spoiler][/spoiler]
func(array)
{
for(elem : array)
{
switch(elem)
{
case 1:
break;
}
}
}
I prefer to go from maximum indentation level to left. That way you know when you're too deep.int main(void) {
for(int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
for (int g = 0; g < 4; ++g) {
// oops looks like I need refactoring
}
}
}
>>62199388
So you dislike formatting?
Best practices :(
>>62195990
>conditional statements
>>62199317
I dont know honestly. switch case statements have their place but sometime just stringing together 3 or 20 if statements looks better and does what you need just fine.
for example in a game if you are about to do an action on a player that works in most situations but in a few situations will crash your own game, its just better to string if statements to check their state, print a warning, and return back to the main menu.
Im sure someone will argue with me about it, but Im just speaking from my experience. the community I was in didn't really make use of switch statements all that much so I tend to completely forget about them.
>>62199595
idealif (condition)
{
}
else
{
}
acceptableif (condition) {
}
else {
}
abominationif (condition) {
} else {
}
If you don't use recommended auto-formatter with recommended style either by your project or by standard language guide before commit&push. Also nothing wrong with the picture.
>>62199619
#2 is best
#1 is for noobs
#3 is for neat-freaks but it's actually less readable
int function(int a)
{
if (a) {
return 1;
} else {
return 0;
}
}
>>62199619
first one is always easiest to read and spacing is always consistent
>>62199619
>I have never written anything else than an hello world application
>>62195990
...you don't use the gnu style
...you use C instead of a proper language like Scheme or ML
...you use windows line ends
>>62199992
>You dont use my stupid language that isn't any better than your language and isn't used by anyone
Never write redundant line breaks or braces.if (a) return 1; else if (b) if (c) return 2; else if (d) return 3; else return 0;
>>62195990
>>62199164
if
(condition)
{ }
>>62199992
You mean "use C instead of Rust"
>>62199619
Swap abomination and acceptable
if (condition) {
# statements
} else {
# statements
}
>>62199434
the thinking mans indentation
>>62200170
Rust is cancer though.
>>62200019
>that isn't any better than your language and isn't used by anyone
Both false.
>>62199619if Condition then
Do_Shit;
else if Other_Condition then
Do_Other_Shit;
end if;
>>62199992
Gnu style is absolute hell
Use a lisp if you want a lisp
>>62200234
>Gnu style is absolute hell
No, it is the most cute and comfy.
>Use a lisp if you want a lisp
I do it anyway.
>>62199674int function(int a)
{
if (a) {
return 1;
}
else {
return 0;
}
}
Here, fixed that for you.
>>62200263int function(int a) {
if (a)
return 1;
else
return 0;
}
>>62199674
>>62200263
>>62200293
All of these are about as satanic.
>>62200263
int function(int a)
{
if (a)
{
return 1;} else
{
return 0;}
}
>>62200329int function (int a) {
if (a) return 1;
return 0;
}
>>62200348
Literally you.
>>62200387
https://vid.me/GGEUb
(if (cond)
(block1)
(block2))
Who needs if statements when you can do everything with the ternary statement? Then you're the spawn of Lucifer:
(condition) ? doSomething() : null;
>>62200406
This site does not work with youtube-dl. Got another one?
Egyptian brackets for everything in Java and JavaScript (Pajeets don't know or care that K&R style brackets in JavaScript can actually change the meaning of your code in edge cases).
Kernel style for C and C++: K&R for functions and Egyptians for control statements.
Anything besides this and you are Pajeet.
>>62200263int function(int a)
{
if (a){
return 1;
}
else {
return 0;
}
}
Please do not put a space in there.
>>62200464int function(int a)
{
if (a){
return 1;
}
else {
return 0;
}
}
Perfected that for you.
>>62200464
This is madnessvoid foo (void) {
if (condition) {
statement;
}
else {
statement;
}
}
tfw you join a project and it follows this shit
>>62200496
and you can't fix that.
>>62196136
I generally strive to follow the recommended guidelines for the language I'm working in. However, if they recommend something fucking retarded like braces on separate lines, or spaces instead of tabs, then I'm not going to follow that. Those things are just objectively retarded.
I don't care what language it is, the only correct way to format it is like this:if (condition) {
} else {
}
This is the cleanest, neatest, and most readable. Each chunk of the if statement takes up exactly one line. With braces on new lines, the start of the if statement takes up two lines and the end of it takes up one line. That's messy and inconsistent.
if (condition) {
// statement
}
else {
// statement
}
because that's the best format for Notepad++
>>62195990
I just do CTRL+A then CTRL+SHIFT+F. Works all the time.
if (condition) {
} else if (true) {
}
>>62195990(if (conditional)
...
...)
Fixed.
>>62199674
>>62200263
>>62200293
>>62200348
>>62200464
>>62200492
>>62200496
Truly awful.(define (function a)
(if (a)
1
0))
step aside brainletsint result;
condition
? (result = 1)
: (result = 0);
>not writing the whole program on one lineint main(){ if(true){ int i = 1; for(i=1;i>0;i++){ printf(i) } } return 0; }
>>62201764
if (condition) { } else if (true) { }
int function (int a) {
if (a) {
return 1 ;}
else {
return 0 ;}}
>>62202329
Smart.
>>62199674
>karlie tier
bool b = a;
>>62195990
...you program in (((lisp)))
>>62195990
https://www.kernel.org/doc/html/v4.10/process/coding-style.html
If you are using any other coding style then you are fuckin retarded.
You are autistic if you don't write it in single line like thisif(condition){//statement}else{// statement}
Prove me wrong
>>62195990
I thought this until I had to read somone else's program in that style.
The real battle is between:if (test) {
x++;
}
else {
x = 0;
}
vs.if (test) {
x++;
} else {
x = 0;
}
Is this thread a representation of that infamous Autism I've heard so much about?
if
( condition )
{ //expression}
>>62199277
That doesn't mean much
>>62195990
I'm sorry, man.
But fate has decided for me to be a PHP developer, and PSR-2, the one and only code style that all code bases that have a code style follow, dictates for it to be this way.
To be honest, I think python does it best. Why would you even need braces if you indent anyway?
>>62199674
>>62200263
>>62200293
Ew, how awful.
>>62200348
Beat me.
Return in almost every language is an implied exit from an enclosure.
If it isn't, it is shit.
Redundant code is worst.
Even if you suddenly needed to add more complex code behind the return 0, say you wanted to return an error code to the caller, it's a trivial highlight and start typing "else {" etc.
Less work than highlight multiple lines, less overhead in code, less overhead when/if compiled / interpreted. It's wins all around.
>>62200987
t. pythonista