This is a question for people more experienced with Python, but everybody feel free to answer if you feel like you can provide something decent to the discussion.

Also feel free to explain why you feel that way and your experiences with Python and the paradigms.

  • Diplomjodler@lemmy.world
    link
    fedilink
    arrow-up
    21
    arrow-down
    2
    ·
    1 day ago

    I used to struggle with OOP because all the explanations I saw were in terms of metaphors of real world objects. Once i started seeing OOP as a way to better structure your code, it all fell into place. If you do anything marginally complex, OO is the way to go.

    • FizzyOrange@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      15 hours ago

      I disagree. You can write a lot of high quality Python code (yeah it exists) before you need to use inheritance. If you’re reaching for inheritance as the solution to all complexity, GoF-style, then you’re doing it wrong.

      It’s an occasionally useful tool that has its place, not something you should instinctively reach for.

      • Sleepkever@lemm.ee
        link
        fedilink
        arrow-up
        3
        ·
        15 hours ago

        OOP not just inheritance. Object oriented programming starts with structuring things in objects, like the name suggests. It quickly has a place in anything more then a few hundred lines of code.

      • Diplomjodler@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        15 hours ago

        I rarely use inheritance. Like i said, I see OOP mainly as a way to achieve cleaner code structure and better readability. That last point is really my main concern.

      • Diplomjodler@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        1 day ago

        I was talking about Python specifically. And no, of course it’s not a silver bullet. It’s a solution for structuring your code base in a way that lets you not lose track of what does what.

        • phutatorius@lemmy.zip
          link
          fedilink
          arrow-up
          1
          ·
          4 hours ago

          It’s also a good way to structure your code to effectively model your problem domain.

          And there are also many cases where that’s not true, so use it where it makes sense and don’t use it where it doesn’t.