There are so many definitions of OOP out there, varying between different books, documentation and articles.

What really defines OOP?

  • HyonoKo@lemmy.ml
    link
    fedilink
    arrow-up
    35
    arrow-down
    2
    ·
    1 year ago

    Instead of making one big mess, you make multiple smaller messes and stuff them into objects.

  • Kache@lemm.ee
    link
    fedilink
    arrow-up
    27
    ·
    edit-2
    1 year ago

    You’re getting a lot of conceptual definitions, but mechanically, it’s just:

    keeping state (data) and behavior (functions) that operate on that state, together

    At minimum, that’s it. All the other things (encapsulation, message passing, inheritance, etc) are for solidifying that concept further or for extending the paradigm with features.

    For example, you can express OOP semantics without OOP syntax:

    foo_dict.add(key, val)  # OOP syntax
    
    dict_add(foo_dict, key, val)  # OOP semantics
    
  • maynarkh@feddit.nl
    link
    fedilink
    arrow-up
    24
    arrow-down
    1
    ·
    1 year ago

    Dude, you’re going to shit bricks when you realize most computer science jargon is just marketing buzzwords on top of marketing buzzwords and the terms never meant anything more or less it needed to sell a product.

    For example, what the hell is big data? What is a scripting language? Is your DB web scale?

      • maynarkh@feddit.nl
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        datasets large enough that it was impractical to try to store or work with them in a traditional relational database software

        How I remember it is that it’s not even the whole dataset that is too large, but the individual records. Hadoop for example is not doing anything magic, it’s just a software package to extend MySQL to be able to efficiently have pictures (Facebook’s original use case, of course it evolved) as records.

        I guess big data is what you need it to justify what you want to justify. In one of my gigs’ case, it was public funding for a project.

    • vexikron@lemmy.zip
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      1 year ago

      Wait, so, the Cloud is actually just a bunch of other computers, called servers, and the only real innovation is basically a load balancing system?

      Next youre gonna tell me I wont be able to stream lagless video games and also do competitive multiplayer on my Google Stadia, pff, like youre some kind of expert or something.

      /s

      • maynarkh@feddit.nl
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        I wont be able to stream lagless video games and also do competitive multiplayer on my Google Stadia

        Negative latency!

  • Rikudou_Sage@lemmings.world
    link
    fedilink
    arrow-up
    18
    ·
    1 year ago

    OOP on its most fundamental level is the principle that stuff is represented by objects and those objects communicate with each other. That’s it, that’s the whole OOP.

    What you are probably referring to is how OOP solves different problems and the different patterns it uses. Those are not OOP itself, those are basically instructions on how to do OOP correctly without shooting yourself in the foot.

    So SOLID, IoC, dependency injection, factory, composition over inheritance and all the other famous principles are not OOP itself, but any medium-size app that’s not following them is set for really fun times ~5 years down the road.

    Not sure if I’ve answered your question, it’s really vague, feel free to ask further.

  • muhanga@programming.dev
    link
    fedilink
    arrow-up
    8
    ·
    edit-2
    1 year ago

    Which OOP? Alan Kay meant this:

    OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I’m not aware of them.

    But there is also various other OOP around. And those really about completly different things.

    • BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      It’s simply not true that there “aren’t really that many definitions of OOP”, much less that the guide you’ve linked is “comprehensive” when it is specifically about Java.

      This is a good, brief post about the different conflicting definitions: https://paulgraham.com/reesoo.html

      This is a much more comprehensive but also less focused overview, with many links, from a site that is effectively both a wiki and a forum: https://wiki.c2.com/?ReesOnObjectOrientedFeatures

      • sirdorius@programming.dev
        link
        fedilink
        arrow-up
        2
        arrow-down
        3
        ·
        1 year ago

        Academically, you’re right. For practical reasons, you probably don’t care how Simula, E, Lisp and Smalltalk (languages mentioned in that 20 year old article) implement it. This seemed more like a beginner question so I think the Java definition is a good starting point.

    • matcha_addict@lemy.lolOP
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      the comments in this thread show that there are different answers to the question, including different from this post.

      Nonetheless, I appreciate the link. It’s a good read.

  • tunetardis@lemmy.ca
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    1 year ago

    Ok, so in most languages, you have some way to define a data structure. It could be anything. Maybe it stores the X and Y coordinates of a Cartesian vector. And now you want to do stuff with your vectors, so you write a bunch of functions you can call like get_vector_length(myvect) or add_vectors(vect1, vect2).

    In OOP, you add that kind of functionality into the data structure itself. So now you can just write myvect.length() or vect1 + vect2 (by implementing the + operator for your data structure). At this point, the data structure is typically called a “class” and the functions you build into the class are “methods”.

    As you dig deeper into it, you learn about inheritance. When you have 2 related classes that share a lot of functionality, you can use inheritance to save a lot of duplication in your code.

    In statically-typed languages, it can also come in useful to have a base class you can pack into a container, since most containers can only accept a single data type. If you had some graphics classes like Rectangle and Circle that all inherit from Shape, you could make a collection of Shape that’s a mix of those. (In dynamically-typed languages, this tends to be less of an issue since you can put objects of any data type straight into the list. This might be why OOP isn’t approached as soon in tutorials for such languages, since it’s not as mission-critical? But it’s still a good idea to have some sort of class hierarchy where it makes sense.)

  • macniel@feddit.de
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    edit-2
    1 year ago

    What kind of different defintions have you came across?

    In Essence, OOP: you describe with your code Classes and how those classed Objects interact with each other. Classes can be inherited from other Classes and or implement Interfaces (Interface, Traits, Protocol) so you know how derived classes can be interacted with even though you don’t know the concrete class until runtime execution.

    The tradeoff would be the stringent nature of OOP: you need to have Objects, otherwise it’s just functional/procedural programming with extra steps.

  • porgamrer@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

    It’s similar to any tech buzzword. Take “agile” for example. Agile was successfully sold as being a great idea without really being well-defined. Suddenly anyone selling a development methodology had a strong incentive to pitch it as being the real way to do agile development.

    In the 90s and 2000s every 10x california tech guru agreed that OO was the future, but apparently none of them actually liked smalltalk. Instead, every new language with a hint of dynamic dispatch suddenly claimed to represent the truest virtues of OO.

    There are also people who argue that smalltalk is not true OO. They say that by Alan Kay’s own definition the most OO language is Erlang.

    I think it’s most useful to learn about that history, instead of worrying about people’s post-hoc academic definitions.

    • matcha_addict@lemy.lolOP
      link
      fedilink
      arrow-up
      10
      arrow-down
      1
      ·
      1 year ago

      OOP is one of, if not the most popular programming paradigm. Surely understanding it at a theoretical level isn’t useless. It would be the first step to understanding its benefits and trade offs.

      • bizdelnick@lemmy.ml
        link
        fedilink
        arrow-up
        1
        arrow-down
        4
        ·
        1 year ago

        Theoretical level is useless, believe me. What is useful is understanding at intuitive level. You can achieve it with or without knowing theory, but you need a lot of practice anyway. Also, different languages providing OOP actually encourage different approaches. You have to follow one that your PL is suited to and that is the best solution for your current task, not that OOP or any other paradigm dictates you.