• henfredemars
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    6 hours ago

    I’ve seen some surprisingly fragile OOP solutions that require tons of internal knowledge about how the classes work. It seems to be a popular approach to writing code that just isn’t very flexible.

    • nous@programming.dev
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      1
      ·
      5 hours ago

      It requires you model your problem perfectly from the start, then it can work alright. But in reality you cannot know the future and when new requirements come in that don’t fit the model you created you are left in a crappy spot of needing to refactor everything or just cram it in however you can.

      • henfredemars
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        3 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
          2
          ·
          45 minutes 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.