• henfredemars@infosec.pub
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    5 hours ago

    I recently did some refactoring with injector and composition patterns already there and it was a breeze.

    OOP isn’t bad but like anything it requires some care.

    • nous@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      ·
      3 hours ago

      Note that I am explicitly calling out inheritance here rather than OOP as a whole. There are many things about OOP that are not that bad or quite ok, like composition for instance. It is generally badly designed inheritance that leads to

      require tons of internal knowledge about how the classes work

      And it is very hard to create a good inheritance structure that does not devolve over time as new requirements get added. While there are other patterns that OOP languages have started to adopt in more recent years (like composition and interfaces) that solve a lot of the same problems but in a vastly more maintainable way.

      • MajorHavoc@programming.dev
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        1 hour ago

        is very hard to create a good inheritance structure that does not devolve over time as new requirements get added

        That’s such an important point. Whatever else folks take from this thread, I hope they catch that.

        And I’ll pile on to add - more layers is more risk. One layer of inheritance is a lot easier to keep maintaining than inheritance that goes four layers deep.

        • nous@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          ·
          10 minutes ago

          And if you only have one layer then why not just use interfaces/traits? Which are a vastly better design than inheritance.