• 1stTime4MeInMCU@mander.xyz
    link
    fedilink
    arrow-up
    11
    ·
    2 years ago

    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
      link
      fedilink
      arrow-up
      10
      arrow-down
      1
      ·
      edit-2
      2 years ago

      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
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        2 years 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.

      • Blackthorn@programming.dev
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        2 years 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
          link
          fedilink
          arrow-up
          3
          arrow-down
          1
          ·
          2 years 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.