1228
you are viewing a single comment's thread
view the rest of the comments
[-] Blackthorn@programming.dev 3 points 1 year ago

Well I guess the point is that you shouldn't need all these method calls to achieve simple goals. Most of those "getF" are calls to some SystemFactory to get a GenericObjectFactory and so on and so forth.

[-] Anomandaris@kbin.social 3 points 1 year ago

This just tells me you don't use Java. Factory classes are just used to create objects in a standardized way, but this code isn't creating anything, it's just getting nested fields from already instantiated objects.

[-] squaresinger@feddit.de 4 points 1 year ago

Thos code is obviously nonsense to show the issue.

But other languages would simplify stuff. For example, some languages call getters implicitly, so .getField() becomes .field. Same with list indexing, which could be done with operator overloading, so x.get(i) becomes x[i].

In this situation that would be able to reduce the character count a fair bit.

[-] biddy@feddit.nl 2 points 1 year ago

The new convention in modern Java is to use .field() instead of .getField().

What you're complaining about isn't Java, it's object oriented programming, which Java basically forces on you. Verbosity is a flaw of OOP.

[-] squaresinger@feddit.de 1 points 1 year ago

Compare:

x.field[5]

with

x.getField().get(5)

Both are exactly the same level of OOP, but the Java version is roughly twice as long. Add operator overloading to the mix and it becomes much worse:

x.getField().get(5).multiply(6).add(3)

vs

x.field[5] * 6 + 3

All this has nothing to do with OOP, but with syntactic sugar that is applied.

[-] biddy@feddit.nl 1 points 1 year ago

As I said, the convention is now x.field() not x.getField()

What language are you comparing against here? x.field[5] is valid Java if field is a public array, but that's not OOP, at least not in a pure sense.

[-] squaresinger@feddit.de 0 points 1 year ago* (last edited 1 year ago)

It's not valid Java for e.g. Lists, Maps, Strings or any programmer-defined classes.

Same with operator overloading.

myVectorA + myVectorB is not valid Java, but it is valid OOP in e.g. Python or C++. And this kind of syntactic sugar reduces verbosity enourmously, while still being OOP.

If you have ever worked in e.g. Python, Groovie or Kotlin you notice quickly how non-verbose OOP can be.

It seriously is just Java.

And Javas insistance on having you wrap non-OOP things in fake OOP constructs (e.g. static methods, which are just functions in modules, but you have to uselessly abuse classes as modules) isn't helping either.

[-] Anomandaris@kbin.social 2 points 1 year ago

But that's functionally no different than what's already there...

The reason the lines are so long isn't because of anything Java related, it's because of the field names themselves.

[-] squaresinger@feddit.de 1 points 1 year ago

Your post doesn't seem to answer to anything I said in my post. Did you answer to the wrong post?

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

Programmer Humor

19623 readers
1 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