Minutely reminder that if you place your opening curly brackets in a separate line...

minutely reminder that if you place your opening curly brackets in a separate line, your taste in anime is as weak as your coding skills

Other urls found in this thread:

kernel.org/doc/Documentation/CodingStyle
twitter.com/AnonBabble

I only watch the best of the best animes

>stop liking what I don't like
>stop typing how I don't type

Enjoy your autism, OP

Reminder that if you put curly brackets to a conditional that contains a single line expression you should end your existence.

Golang does not have this problem.

Says the guy who starts its function names with uppercase char.

It's not that simple actually. For functions, you place the opening brace on a separate line. In all other cases (if, while, do, for, switch) you place it on the same line. That's the One True Brace Style as handed down by K&R.

your degenerate excuse of "liking" the way it is is the reason amerifags still use measuring standards from the middle ages

It's better to put them there both for clarity as well as in case the conditional block is expanded with more statements later.

Remainder that if you don't just use whatever clang-format spits out tuned for the project's coding style, then you are overly autistic.

kernel.org/doc/Documentation/CodingStyle

>However, there is one special case, namely functions: they have the opening brace at the beginning of the next line

Linus would fire you.

>amerifags
In the UK we still use them...

>It's impossible to add them later when they're required

Jeez better write every line of code inside of a function in its own class just in case we want to expand on it later.

How about this?
##code
isCacheValid ? resetFilterToDefaults() : RepopulateCatalogFromService();
##code

has there ever been a legitimate use for that ternary operator?

I use it all the time. It's shorter, neater, and feels less wasteful, even though it really isn't.

>drastically reduce readability to save less than one line
Explain yourself

>reduce readability
not really
>save less than one line
it saves exactly one line

Or let's play with Java, using some wrapper classes and static interfaces that should be part of your utils unless you're a cuck:

//code...
if(cacheIsValid).then(this::resetFilterToDefaults()).otherwise(this::repopulateCatalogFromService());
//code...


Tell me that isn't readable. Tell me that can't be understood by a five year old.

}
else {

This is the worst thing I've ever seen.

i agree. that isn't readable at all. i can only hope it's a troll

Joke's on you, I don't watch animeme.

Because? The short code width of the code-tag makes it sorta shitty, but it could easily be written like this:
//code...
if(cacheIsValid).then(this::resetFilterToDefaults())
.otherwise(this::repopulateCatalogFromService());
//code...


Hopefully, it'll obey the spaces/tabs I put in, but hell, even this works:
//code...
if(cacheIsValid)
.then(this::resetFilterToDefaults())
.otherwise(this::repopulateCatalogFromService());
//code...


On what basis? It's different? In my experience as a developer, when people say "it's not readable" it's because they're generally dumb people who can't understand something unless they've seen it every single day for years. The whole resistance put up by many programmers is simply an opinion or desire they can't logically or rationally back up, which betrays their entire role as a programmer.

My proposal is, this way of writing it (I don't do it myself FYI) is easy to understand for EVERYONE except a narrow-minded, pretentious programmer. Show it to your mom, and she'll understand it because it's basically a complete, english sentence.

>goto fail;
lolno

Opening function/method: Brace on a new line
Everything else: Brace on the same line

why is Sup Forums all about metaprogramming and fizzbuzz? don't any of you do any real programming?

No.
>sample

And if you need to add a new statement, you need to change all your code block.

- using 'then' which is implied for 'if'
- using 'otherwise' instead of conventional 'else', also 'otherwise' only makes sense here because your condition includes 'Is'.
- Continuated statements with no indication at all they are when breaking the line
- Line is horribly long and convoluted when not breaking the line
- Works for boolean comparisons only, try to add an elseif to this without ruining it

Please, I understand people complain to you about readability. New attempts like these ("I created my own {readability|best practice|statement|operator}") are generally proposed by people lacking the experience to understand why it's not used. I totally encourage you to come up with such things, play around with them for a month and then realize you fucked up. Failing on stuff like this multiple times is what creates the good devs.

I don't see the problem

>metaprogramming

That word doesn't mean what you think it does cuck

The tale of the Java program who wanted to be Python.

Literally the only post in the thread worth reading right now. OP, what the flying fuck is this shit?

This actually makes Java much more readable.

>Reminder that if you put curly brackets to a conditional that contains a single line expression you should end your existence.

if (x.IsEmpty())
Console.WriteLine($"We got no stuff.");
else
{
Process(x);
Console.WriteLine($"Stuff sent for processing.");
}

>daily reminder that sun is very hot
gee, thanx i guess

my taste in anime is impeccable, and i put my curly brackets so that matching ones are on top of each other, like any sane human being.

good day, sir.

What? Do you even program? I said, I don't use this myself, but playing around with this in our heads is trivial.

Else if? Come on, you're acting like idiots, you know how easy we'd add that:
//code...
if(cacheIsValid)
.then(this::resetFilterToDefaults())
.elseif(this::someOtherCondiiton)
.then(this::someOtherMethod());
//code...


See, was that hard? The "otherwise" and "then" is just sugar to make it read more like an english sentence. "else" doesn't lend itself well for that purpose. Don't want it?
//code...

if(cacheIsValid, this::resetFilterToDefault).else(this::repopulateCatalogFromService());

//or...
if(cacheIsValid, this::resetFilterToDefault)
.elseIf(someOtherCondition, this::someOtherFunction)
.else(this::repopulateCatalogFromService);
//code...


Of all the dumb, vague and outright wrong stuff you've written so far, none of you have actually mentioned why this is retarded to use in general: performance. The performance is likely to be a factor of four to ten times slower, and imagine using this in a loop processing thousands if not hundreds of thousands of objects.

Basically, you're both shit programmers if you even are programmers, even going as far as lying.

I almost vomited reading that horrendous code :/

thread();

> See, was that hard?
Now, append a call to this::stfu if cache is valid. You can't.

> none of you have actually mentioned why this is retarded to use in general
> The performance is likely to be a factor of four to ten times slower
Actually, this is fully retarded and I won't even compile it. Who care about performance then ?

Why do you have such a half baked system anyway?

Last time I talked to an Englishman he had his phone on 24 hour clock and temps in Celsius but also using miles, but also millimeters

Aussies are the same, except they use the filthy 12 hr format :/

Look at the second example.

It'll compile. It's backed by static interfaces, static imports which hides the utility-class I mentioned earlier backing it all up.

So yes, it's merely a matter of looping over static interfaces and calling them. The reason not to use this is because it's slow and really pointless, it just makes everything readable as a single sentence giving an instruction, again given that you've named your methods right.

It cannot replace and if statement always though. The conditional expression must be of a certain type, thus in a?b:c both b and c must be of the same type, it won't work otherwise (compile time error). With an if, you can do whatever you like in both clauses.

>vomitingdog.jpg

Digital 24 hour clocks are better, its far easier to tell what time it is and your less likely to read it wrong by missing out AM or PM. It adds a lot more context to the time. You know 23:00 is late, 11 could be late or early

Celsius is always better than F so dont give me that

We use different measurements because I dont know its easier or something why not we have both never settle thats what someone said

Oh but that's not all, the example I wrote won't even compile unless they all return a value, and the statement won't be assigned to something. Here's expanding it:

public static void main(String[] args) {
boolean check = true;
boolean value = check ? getOneBoolean() : getAnotherBoolean();
}

public boolean getOneBoolean() {
return false;
}

public boolean getAnotherBoolean() {
return false;
}


So yeah, I only use the ternary. But you can make any void function into a boolean function, and then it'll execute whatever is in that function.

public static void main(String[] args) {
System.setProperty("hurr", "durr");
System.out.println(System.getProperty("hurr"); //prints "durr"
boolean check = true;
boolean value = check ? doSomeWork() : doNothing();
System.out.println(System.getProperty("hurr"); //prints "Rei is best girl."
}

public boolean doSomeWork() {
System.setProperty("hurr", "Rei is best girl.");
return false;
}

public boolean doNothing() {
return false;
}


But of course, it's retarded and in small cases like this a lot of code for very little.

Kidding? It's beautiful.

> Look at the second example
You're brain have performance issues. My point is if you want to call both this::resetFilterToDefault AND this::stfu when chacheIsValid == true, you're fucked. Thus, you're code is not evolutive, over engineered and unreadable. This is bad, you're bad.

You're just trying to show off. You've understood new Java 8 mechanisms, good for you. Guess what : no one cares.

>My point is if you want to call both this::resetFilterToDefault AND this::stfu when chacheIsValid == true, you're fucked

lol no
if(cacheIsValid, this::resetFilterToDefault, this::stfu);


not really hard, is it?

public class IfUtil {
public IfUtil if(boolean value, Method... methods) {
for (method :methods) {
method.execute();
}
}

public interface Method {
void execute();
}

}


it just werks

>//code...
>if(cacheIsValid)
>.then(this::resetFilterToDefaults())
>.otherwise(this::repopulateCatalogFromService());
>//code...

You're modifying your code on the fly.

it's called Pascal case, as opposed to camel case

>not } else {

I do new line and I hate anime. I also have sex with 3d women.

Your FagCase really helps to identify classes vs functions and variables.

Like I said: sugar. Syntactic sugar. Provide plenty of methods which function correlates to their names. To make it possible for any one person speaking english to read and understand: language.

Do this for real in production code? No, don't. For the love of god, don't. On Sup Forums? Yeah, why the hell not.

That image is actually objective fact. The one on the left is wrong, because it's not consistent. The curly brackets of the if and else statements should also be on a separate line.

> Provide plenty of methods which function correlates to their names
You've basically replaced "if" keyword with an "if function, the "else" keyword with an "else" function, ... via a shit-ton of boilerplate code.

I'm okay, you can do it, but it's dumb.

>I'm okay, you can do it, but it's dumb.

Which is precisely what I said. But - it'd be more readable in both the literal sense and the practical sense - if done right.

also

if (cacheIsValid) { doSomething(); } else { doNothing(); }

//vs

if(cacheIsValid).then(do::something).otherwise(do::nothing);

We already have the possibility, this is just making it look more like a sentence. For what reason, god knows, but the purpose and intention becomes instantly clear.

In the future, code might look like this:
Create the webpage as shown in figure 1, then add a sidebar. Connect to the first company web service.


meaning a lot of us will be out of a job.

Pajeets, all of you.

Nope. You came to us with this, saying:
> My proposal is, this way of writing it (I don't do it myself FYI) is easy to understand for EVERYONE except a narrow-minded, pretentious programmer.

If I face this in a codebase instead of a standard control structure, I'll get mad. Because it potentially brings the same problems overloaded operators have in C++. It's not because a function is called "IF" or "THEN" it actually does what you think.

If you don't like the syntax of a language, use another one. Don't try to feature bend it to your personal convenience.

>My proposal is, this way of writing it (I don't do it myself FYI) is easy to understand for EVERYONE except a narrow-minded, pretentious programmer.

Which is something that's completely true, quoting you:

>If you don't like the syntax of a language, use another one. Don't try to feature bend it to your personal convenience.

You will understand what the code intends to do. You will understand it quicker, easier, but you as a narrow-minded programmer will obviously recoil because you don't know HOW it works. It's different (and worse in terms of performance, admittedly) Acting up about it, getting mad about it because it fails your preconceived notions is what makes you pretentious.

I never advised using this. My point is rather this: and about readability in general. Some time in the future there will be a complete paradigm shift. We're already headed that way with literal drag and drop languages. Ironically, to stay relevant programmers will have to promote readability for themselves but complete obfuscation for everyone else.

When your non-engineer project manager/owner looks at what you write and shudders, you know you're safe.

Following your current argumentory, predicting that some days you can just solve problems by saying to Siri's grandaughter to handle it makes your re-implementation of an already existing java control structure legit because it's a step forward. That's bullshit.

> a narrow-minded programmer will obviously recoil because you don't know HOW it works
Actually, knowing how the internal work is part of the job, at least nowadays. High-level abstraction just makes it easier to operate.

Otherwise, no problem here with natural language programming.

Premium troll, btw :^)

ftfy

public void RefreshCatalog()
{
if (IsCacheValid) {
ResetFilterToDefault();
} else {
RepopulateCatalogFromService();
}
}

But I put all my braces on a new line (with a few exceptions) and my taste in anime is objectively great.

>pascal case

Bullshit? On the contrary. There was only one area I proposed it'd be a step forward, and that's readability. There isn't a single argument against that, the only arguments concern areas I was in fact first to mention, and not only that, I argued it better: performance.

>Actually, knowing how the internal work is part of the job, at least nowadays. High-level abstraction just makes it easier to operate.

It's also your job to understand and adapt new code, frameworks and languages. Not accepting that responsibility just means you're a pajeet.

for things like conditional assignment, obviously.
e.g.
a = (b == NULL) ? NULL : b->ptr;
c |= (destroy) ? FLAG_DESTROY : 0;

Does not compile, degenerate

Hello pajeet.

>that else statement
kys anytime OP
also

> There isn't a single argument against that
- the readability of your very first one liner is horrible
- the readability of your modified version that handle multiple statements is horrible
- the fact it re-implements an existing structure is retarded and dangerous since it adds an unecessary layer of complexity
- the performance is pointless since no one should even bother compiling it given all the above

You want a more readable syntax, make your own language but don't put cardboard wings on my car because some day cars will eventually fly.

> It's also your job to understand and adapt new code, frameworks and languages
your degenerated experimental snippet is not framework

>Tell me that isn't readable. Tell me that can't be understood by a five year old.
It's unreadable and a five year old wouldn't understand it

>- the readability of your very first one liner is horrible
Sup Forums code block width cut it in half, not an argument.

>- the readability of your modified version that handle multiple statements is horrible
Not an argument.

>- the fact it re-implements an existing structure is retarded and dangerous since it adds an unecessary layer of complexity
Necessary because the intention is to change the syntax, which cannot be done as of today without adding said layer. Not an argument.

>- the performance is pointless since no one should even bother compiling it given all the above
Not an argument either.

>your degenerated experimental snippet is not framework
It's new code, just like I wrote. I spoke about your responsibilities, and how your attitude implies a guaranteed failure about fulfilling them.

>You want a more readable syntax, make your own language but don't put cardboard wings on my car because some day cars will eventually fly.

It's not your car, it's not cardboard but carbon fiber, and if it makes the car look "cooler" to someone who doesn't get cars, then guess what, you're wrong. Surely the car will go slower because the cardboard wings just end up increasing drag, but hey, it looks cooler.

Like I said, I advise against using this and don't even do it myself for the only argument that matters: performance. The takeaway for you personally is that you don't understand readability beyond "something I'm used to seeing.".

I asked for that, I guess.

seriously wtf

Top kek.

I obviously can't stop you being stupid and fallacious, I'm done.

>ur stooped

You were always done.

Milisecundelly reminder that op is a faggot.
My code -> my rules -> not your business.

Reminds me of LINQ

The proper convention, at least in C#, is
public void RefreshCatalog()
{
if (IsCacheValid)
{
ResetFilterToDefaults();
}
else
{
RepopulateCatalogFromService();
}
}

That's the Renaissance.

(IsCacheValid ==1 ? ResetFilterToDefaults() : RepopulateCatalogFromService());

8 lines to 1.

Tenantry operators reduce readability.

Sure: such operators are cool but your source code is not supposed to be an art project unto itself.

Yeah, if you nest them. If one confuses you, you should try a different hobby like drawing stick figures.

There's a difference between not understanding syntactic sugar and wanting increased readability. As I said: code should not be an art project.

A similar concept is expressed with technical English (i.e English language for manuals, memos and tutorials) where you avoid writing in prose and using literary acrobatics. There's no room for creative writing in technical English just like there is no room for creative programming, in well, programming.

>Implying that most programmers would go out of their way to use tenantry operators when simple if statements would do.

do people really care about this? just use whatever the project standard tells you to use

Objectively incorrect, there's a reason JavaScript programmers almost universally put curly brackets on the same line as a conditional, and it also happens to be the same reason behind your post: retardation.

This.

The conventions are different for every language and sometimes are different depending on corporation.

else is a keyword

there is always gonna be many different units of measurement

just because metric is based on orders of magnitude doesn't make it any less arbitrary

>Javascript
L
O
L

Using a space between your ) and { makes you the same.

Anime is fucking trash anyway.

That's convention in Java.
It is not convention in many other languages.

Adhere to convention.

you dropped these
if err != nil {
fmt.Println(err)
}
if err != nil {
fmt.Println(err)
}
if err != nil {
fmt.Println(err)
}

It is very useful in c++ as you can write it anywhere.
I could probably give a better example, but I am really tired.
std::cout

>OP still hasn't progressed to a language that has done away with these relics of a hundred years ago

kys

looks more like js promises actually