My physics teacher once gave us a group project to simulate a falling ball’s force and velocity at each millisecond, basic stuff, and my partner wrote the code in C with no libraries using inline assembly. Absolute madman.
if (Boolean.TRUE.equals(condition)) which is what SonarQube's default Java rules will recommend. (edit: in case anyone wonders, it's because of null safety; if (condition) throws an NPE if condition is null, Boolean.TRUE.equals(condition) just evaluates to false)
try {
if (condition) { /* code whatever */ }
} catch (MommaAintRaisedNoCowardException _) {
log.error("No bugs to be seen here no sirreee");
}
public class MommaAintRaisedNoCowardException
extends NullPointerException
{ /* standard exception stuff */ }
Reminds me of one time in a class. I needed to get from one datatype to another with no clear way... I kinda did "variable.toThis.toThat.toAnother.toTarget". Asked rhe teacher if there was an easier way and he just looked at it and went "the fuck is that?" I was all "exactly!" XD
130
u/y0shii3 7d ago
How you do it
vs how your teacher does it
vs how your classmate does it
vs how Spring devs do it
76
u/Ignisami 7d ago edited 7d ago
You're missing
if (Boolean.TRUE.equals(condition))which is what SonarQube's default Java rules will recommend. (edit: in case anyone wonders, it's because of null safety;if (condition)throws an NPE ifconditionis null,Boolean.TRUE.equals(condition)just evaluates tofalse)21
u/yousirnaime 7d ago
if( LlmService.request(" does this seem truthy, respond only 'yes' or 'no' : " . condition) == '{"response":{"message":"yes"}}'){
}
13
u/Simple-Olive895 7d ago
if (myBool == true) {
}
15
u/Varderal 7d ago
Reminds me of one time in a class. I needed to get from one datatype to another with no clear way... I kinda did "variable.toThis.toThat.toAnother.toTarget". Asked rhe teacher if there was an easier way and he just looked at it and went "the fuck is that?" I was all "exactly!" XD
6
u/Dinatoc_208 7d ago
when you're paid per line of code
4
u/Forward_Republic_610 7d ago
I am missing the hangman in the last picture.
3
u/AndromedaGalaxy29 6d ago
second one is good for readability sometimes
3
u/MallAgreeable5538 4d ago edited 4d ago
Istrueclass istrueobject(valuetrue);
if(istrueobject.istrue(boolean)){
2
u/CjMori23 7d ago
This is what the twitter devs that didn’t get fired were writing
1
u/NoodlyGirl2000 7d ago
I do have a lot of fond memories of Java, but I also think C# does it so much better
1
u/induality 7d ago edited 7d ago
The fourth one isn’t even correct. The comparator compare method returns an int. You need to check that that return value equals zero.
1
u/tatstytastycakes 7d ago
class vs homework vs quiz vs exam
1
u/DONARUDO_TURANPU 6d ago
Doesn't Java have some ternary operator like JS? That would be the first image but in full HD 3D
1
u/Zezerok 6d ago
I do most time 1 and sometimes 2 for the readability
1
u/TheSheepDev 4d ago
Java
Jav
Ja
J
1
u/Cat_Player0 22h ago
what is this genre of meme called
1
u/ErdbeerbaerLP 19h ago
https://github.com/SpaghettiBowl/spaghetti/blob/main/spaghetti.java
0
u/ThePhyseter 7d ago
Guy #3 came from Javascript and never learned about == vs ===