• moosh@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    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
      link
      fedilink
      arrow-up
      0
      ·
      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
        0
        ·
        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?

        • Blackthorn@programming.dev
          link
          fedilink
          arrow-up
          0
          ·
          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
            0
            ·
            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.

        • bleistift2@feddit.de
          link
          fedilink
          English
          arrow-up
          0
          ·
          2 years ago

          You shouldn’t reach through an object to invoke a method. That tightly couples the classes which getJ and getG (for instance) return.

          • Anomandaris@kbin.social
            link
            fedilink
            arrow-up
            0
            ·
            2 years ago

            That is an interesting point, but it’s not Java specific, you could do this exact thing in most other languages and it would look pretty much the same.

            Considering the fact that in a lot of enterprise projects the data structures are not necessarily open to change, how would you prevent reaching through objects like this?

    • Eugene@waveform.social
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      Java is a programming language that is notorious for being verbose, the joke is that you need a massively wide monitor to view it without the text being cut off