You dont know OOP

309,583
0
Published 2024-01-31
Recorded live on twitch, GET IN

twitch.tv/ThePrimeagen

Become a backend engineer. Its my favorite site
boot.dev/?promo=PRIMEYT

This is also the best way to support me is to support yourself becoming a better backend engineer.

Article link: blog.sigma-star.io/2024/01/people-dont-understand-…

MY MAIN YT CHANNEL: Has well edited engineering videos
youtube.com/ThePrimeagen

Discord
discord.gg/ThePrimeagen


Have something for me to read or react to?: www.reddit.com/r/ThePrimeagenReact/

Kinesis Advantage 360: bit.ly/Prime-Kinesis

Hey I am sponsored by Turso, an edge database. I think they are pretty neet. Give them a try for free and if you want you can get a decent amount off (the free tier is the best (better than planetscale or any other))
turso.tech/deeznuts

All Comments (21)
  • @junfour
    Real OOP has never been tried
  • @hinduGigaChad951
    Liskov Substitution principle: "If it looks like a duck, quacks like a duck, but needs batteries, you've got the wrong abstraction"
  • @Colonel1954Dz
    Prime talking about traits as if they're fundamentally different from inheritance. A first level trait is an interface (and possibly a base implementation class), combination of traits can be seen as multiple inheritence. Fundamentally, the choice of your 'abstractions' is what defines how well either options do. If you create a bird abstraction with the underlying assumption that all birds can fly, then your abstraction is wrong.
  • @antheus_s
    The "L" response from ChatGPT caught be off guard 🤣
  • @NoodleBerry
    As a C++ enjoyer, structs with functions rock Yes I do create real classes but we love glorified buckets of data
  • I finished your "The Last Algorithms Course You'll Want", and .. it was awesome. You motivation message is now deep in my heart. Thank you for doing this!
  • @defeqel6537
    Just FYI Prime, Liskov's applies to Traits too, and any function pointer(ish thing) edit: as a practical example: a function calls another function via a pointer, and expects that function to return the same value with the same parameters with every call, but if some implementation returns a new value with each call it violates the principle and may lead to incorrect behavior
  • @voswouter87
    The point of getters and setters is that the class can always take control of private data without changing the interface. You can trigger onchange listeners or reject the new value. But no, it almost never gets used.
  • "have you seen this, have you heard about this?" - hi there Jimmy - "wow, what a terrific audience"
  • @davidhenn2987
    Always when I tried to create a good inheritance chain (bird), I later in time find the "ostrich" and have to change all user to "flying bird)....
  • @spencer3752
    41:33 "To a certain extend..." Bro is so OOP-brained he made a Freudian typo
  • @MagpieMcGraw
    Liskov substitution means that when a function wants a "bird" as an argument, you should be able to pass a "sparrow" or a "chicken" and have the program stay correct. In other words, all subclasses must contain all data from their superclass.
  • @sbditto85
    Liskov still applies to interface/trait based programming. It means if something implements the interface it must do so without changing the intention of the interface. You can’t just pick and choose what methods of the interface you implement. (It may meant you need to split the interface or have the design wrong if something can only implement some of the interface)
  • @uima_
    I'm not finished the video yet, but I felt the inheritance in oop is like directory and the trait in rust is like tag in note taking management. And I love use tag more then directory.
  • @blinded6502
    Here's my take on getters/setters: they are useful for math vectors. Just do "vec.length += 2" to make vector longer by 2. Or "vec.length = 1/vec.length". In fact, they are useful for many objects, that can have multiple parametrizations, but internally we just store one parametrization, as to not have multiple types doing same thing.
  • @ivanjermakov
    6:35 "OOP just means we model our problem using these objects", isn't it domain driven design?
  • I think you might be interested in Odins solution to this. While it generally behaves a lot like C, there is support for subtyping and generics. As a bonus there is even an (experimental) feature on the lsp called "fake methods" to make it easier to find the procedures that are associated with a struct.