• bleistift2@feddit.de
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year 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
      1
      ·
      1 year 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?