this post was submitted on 15 Jul 2023
1216 points (98.9% liked)

Programmer Humor

19503 readers
1263 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
[–] [email protected] 13 points 1 year ago (23 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.

[–] [email protected] 15 points 1 year ago (18 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.

[–] [email protected] 16 points 1 year ago* (last edited 1 year ago) (16 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?

[–] [email protected] 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 (15 replies)
load more comments (16 replies)
load more comments (20 replies)