this post was submitted on 15 Jul 2023
1189 points (98.8% liked)

Programmer Humor

19197 readers
1363 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] moosh@lemmy.world 12 points 1 year ago (22 children)

Is this a good thing I’m looking at or a bad thing? I don’t get it but then again, I’m not a programmer.

[–] 1stTime4MeInMCU@mander.xyz 14 points 1 year ago (17 children)

The joke is Java is verbose. It takes many characters to accomplish simple routines. Depending on your view that could either be good or bad for reading the code later.

[–] Anomandaris@kbin.social 17 points 1 year ago* (last edited 1 year ago) (15 children)

Sure, but most of the lines in the screenshot break down to:

object1.setA(object2.getX().getY().getZ().getI().getJ().getK().getE().getF(i).getG().toString())

Aside from creating a method inside the class (which you should probably do here in Java too) how would another language do this in a cleaner way?

[–] fredthedeadhead@lemmy.world 3 points 1 year ago* (last edited 1 year ago)

Kotlin would represent the getter/setters as synthetic properties (and do so automatically, since Kotlin interops with Java).

object1.A = object2.X.Y.Z.I.J.K.E.getF(i).G.toString()

Of course it's still not great (there's still too much nesting, there's something fundamentally wrong with how the data is structured) but at least the code is less noisy.

load more comments (14 replies)
load more comments (15 replies)
load more comments (19 replies)