Why OOP Exists

(mathspp.com)

12 points | by lumpa 3 days ago

12 comments

  • mickeyp 4 minutes ago
    OOP is fine. Not using OOP is fine too if your architecture / design demands it.

    What people forget -- much like the design patterns in the gang of four book -- is that languages and frameworks evolve.

    A decorator pattern was a niche but useful abstraction in the 1990s. In Python today you can @decorate stuff just like that. It's evolution.

    The same holds for OOP. Encapsulation and co-located methods with the encapsulating slots was an incredibly powerful upgrade over basic structs. Now most languages have first-class functions and lexical scoping so you can build your own encapsulation that way.

    It's all good. Just use whatever fits best.

  • mrkeen 22 minutes ago
    Admittedly I read this pretty quickly, but this is just structs.

    The "behaviours" being modelled here were data access. Writing .name() instead of .name.

    You can save yourself the time of manually packing these structs by writing out a constructor in full. Which the article called "automatic".

    (You don't even need to write out the constructor for a struct in C99. Probably any other modern language too)

  • eru 55 minutes ago
  • projectileboy 16 minutes ago
    A good book for appreciating the OO mindset is Object Thinking by David West.
  • Zak 3 minutes ago
    This seems like a beginner-level OOP-in-Python tutorial, and I'm disappointed the author didn't demonstrate a functional abstraction for `find_by`.
  • groomlake 47 minutes ago
    Wayback link since the site was hugged to death: https://web.archive.org/web/20260827081007/mathspp.com/blog/...
  • yxhuvud 21 minutes ago
    > If you think you already know OOP, this article will change the way you think about programming

    No, it won't. I'm especially sad that this, like so many OOP guides before it, did not go into how it interacts with data structures and bigger picture stuff. It had the perfect chance to do that as it could have made a Catalog class and then had a discussion about what belongs to that and what to the books. Instead it started to abstract on author, in the stupidest way possible (no, no one will ever look up a book using the author birth date).

    • fjcururuvy7 15 minutes ago
      The older I get the more I realize the stuff I learned in university was just plain wrong.

      It's incredibly difficult now dealing with zoomers in the workplace that think I'm some old boomer that never learned "proper computer science".

      No, sorry Timmy, it's not because I don't understand microservices, it's because I actually do.

  • wolvesechoes 9 minutes ago
    OOP, like most stuff discussed in dev-related web, exists so that permaonline people can have another reason to create their own tribes and fight each other.
  • echelon 27 minutes ago
    OOP is perfectly fine.

    Rigid class-based inheritance (especially multi-inheritance) is what sucks. This over-engineered complexity really only benefits things like window toolkits where you want super rigid modeling of widget types. But even that's a stretch.

    Traits do OOP the right way. Complete flexibility.

        Dog goes "woof"
        Cat goes "meow"
        Bird goes "tweet"
        And mouse goes "squeak"
    
    Does not need classes.
    • garretraziel 24 minutes ago
      Not sure if intentional, but I read it in Ylvis’ “What does the fox say?” and now I can’t get it out of my head, thank you very much.
  • phplovesong 15 minutes ago
    There is good OOP, there is bad OOP, and then there is PHP(OOP).
  • victorbjorklund 48 minutes ago
    Site died.
  • OtomotO 45 minutes ago
    OOP exists to add a quadrillion of layers to otherwise perfectly understandable business code in an attempt to obfuscate meaning and intent and guard against malicious extraction of valuable trade secrets.

    Oh, it also helps me to pay my bills, because someone has to untangle the mess.

    And it helps my therapist, because he has to keep the madness that grows inside of me in check.

    Jokes aside: I was taught OOP at university.

    I was also taught functional programming, answer set programming and other forms such as logical programming.

    Focus was definitely on OOP though.

    I mainly see OOP as a way to (dis) organizer code and a way for hardware manufacturers to sell more hardware.