• squaresinger@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        2 days ago

        Have you ever seen a real-world project that actually uses OOP in any significant capacity? I haven’t.

        When using Java, you might write “class” on top of your structs and modules, but actual OOP with self-contained classes that contain both data and business logic using inheritance and all the other OOP concepts, that’s incredibly rare.

        • zerofk@lemmy.zip
          link
          fedilink
          arrow-up
          1
          ·
          18 hours ago

          I have seen and worked on many projects that use inheritance, polymorphism, interfaces, all the staples of OOP. It’s true that none of these use only OOP principles and applies them rigorously. Real world projects are almost? always a mix of many different paradigms, because the truth is no one paradigm matches all use cases - and every programmer is only familiar with a few anyway.

          This is one of the ways I believe Java went wrong: the program entry point is naturally a function, not an object. Wrapping main in an object makes little sense. Similarly, having absolutely everything inherit “Object” is forcing OOP where it doesn’t belong.

          But that doesn’t mean OOP isn’t used in the real world. It is.

          • squaresinger@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            18 hours ago

            I could maybe have been clearer when saying “significant capacity”.

            Most projects I worked in did use OOP in some capacity, but only in quite small amounts.

            My point mainly was that a lot of people think that using the keyword “class” for structs (aka data classes) or modules (aka service/controller classes) counts as OOP and that’s not the case.

            But I agree that Java and similar languages could use some other type of syntactic sugar for modules. But then again, it would literally just be another name for the same thing.

      • fibojoly@sh.itjust.works
        link
        fedilink
        arrow-up
        9
        ·
        2 days ago

        Like everything that’s impressive at first sight, but misunderstood because you never go past that first impression.

        • mnemonicmonkeys@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 day ago

          While the concept has it’s uses as a tool, the fallacy that OOP advocates fall into is overusing it.

          I’ve seen many people completely swear off of using scripts, which is absolutely ridiculous. While you may use some tools more than others, swearing off an entire code structure for no reason is ridiculous.

          Say there’s a module of code you need to write that has hundres if not thousands of variables that come into play in combinations that would be extremely difficult to organize as functions. You’re then stuck with passing all those as inputs and outputs between functions.

          Sure, you could organize all those variables as a giant array and pass them around as one big block, but at that point you’re just emulating the shared workspace that you get with scripts, and you’d just be better off working with scripts from the start.

          The issue with OOP is that it completely ignores this reality and insists that nobody should ever need a script, and if they think they do then they just aren’t clever enough.

          • Valmond@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            19 hours ago

            Well you’re not wrong, but man, you’re hating the screwdriver because you work in a bolt factory.

            Use the took that best suits your problem, right?

            Also: what’s that code that has thousands of variables that cannot be organised? If it isn’t just an example for the sake of an example, I’m genuinely curious! And how does scripts “fix” that?

            Also: I have always hated java for their overuse of OOP, but also restricting its use, wtf.

            Also: I love a straightforward script, on linux at least!

            • mnemonicmonkeys@sh.itjust.works
              link
              fedilink
              English
              arrow-up
              1
              ·
              7 minutes ago

              Well you’re not wrong, but man, you’re hating the screwdriver because you work in a bolt factory.

              Like I said, the problem with OOP advocates is that most of them are calling for bolts to be destroyed in this analogy. If they weren’t so fanatical about it we wouldn’t be havining this conversation.

              what’s that code that has thousands of variables that cannot be organised?

              It’s not a random example. I can’t go into detail, but it’s the code I work on on a daily basis. It’s a physics model for industrial equipment. Highly customizable for customers, and I need to know exactly where various sub assemblies are located and be able to move them in various configurations.

              And scripts doesn’t “fix” the problem. It’s more that using functions is infeasible due to the difficulty in cramming everything into input arrays, so scripts end up being orders of magnitude more efficient to work with. The scripts are all called from a function, which does allow us to interface with other groups or our own custom GUI.