Why was OOP Invented?

Поділитися
Вставка
  • Опубліковано 22 лис 2024

КОМЕНТАРІ • 120

  • @thomashenry7218
    @thomashenry7218 5 років тому +50

    Stefan, you communicate with us like a wise father or uncle would. I never notice any inflammatory, condescending remarks or undertones in your videos, or trying to put someone else down. This world needs more of that. Very positive, edifying channel!

  • @llamasarus1
    @llamasarus1 10 місяців тому +2

    People talk about OOP as if inheritance is all there is to it or is the most important aspect of it when there are so many other things that give it its identity.

  • @joshuakaufmann4081
    @joshuakaufmann4081 5 років тому +26

    Ruby is an almost pure object oriented language.
    Thought that would be good to mention this on this chanel

    • @mitjed
      @mitjed 5 років тому +6

      Stefan loves ruby

    • @taariqq
      @taariqq 5 років тому +1

      lol

    • @joshuakaufmann4081
      @joshuakaufmann4081 5 років тому

      @a 2345193 , True. I said almost pure because I was actually thinking of the other two examples. Ruby is the "objected enough" language to give someone a good feel for object oriented programming.

    • @bilaljamaludeen6535
      @bilaljamaludeen6535 3 роки тому

      Python

  • @mrcrackerist
    @mrcrackerist 5 років тому +4

    i would say that a mix of procedural and oop is the best just my opinion do. when you have lots of simllar stuff use oop. when you have function (not methods) that are used every where or the main function use procedural. doing pure procedural right now its really fun compered to oop.

  • @hattrickster33
    @hattrickster33 5 років тому +20

    When I was first starting out I admit I'm one of those people who overused inheritance because every book and tutorial made it sound like the best thing every invented. As I started getting into more complex systems, I saw the weaknesses that you mentioned. You can end up with an unmaintainable system if you blindly use inheritance for the sake of reusability.
    I think the thing to remember is that inheritance does have its place. Obvious example: if you're writing any Java, you're automatically using inheritance because everything in Java inherits from Object by design. Also, I've used inheritance sparingly in the data layer where the app is interacting with the database. Basically the kind of logic that all the data classes will be using, like setting up the connection, closing connection, etc. That's one case where it makes sense.

    • @aoeu256
      @aoeu256 5 років тому +1

      The big problem is that in schools Java, C++, and C# are sold as "industrial" languages where thats how the "big boys" code. However, the most reusable and least error prone code is actually purely functional code with immutability. You can create functional OOP in Java by instead of writing getters and setters you would create an alternate constructor that would return a new object based on an old object and new parameters you want. This allows your code to compose more. This is actually easier in JavaScript. var newvector = makeVector(oldVector, {z:5}) rather than oldVector.setZ(5). This makes it easier to nest your new objects, and you can't get data incoherence and NullPointerExceptions (caused by sequencing your code wrongly) this way. Sequencing errors are actually more common than all other forms of type errors found by Java combined.

  • @RetributionAnon
    @RetributionAnon 5 років тому +2

    I don't know why, but I love your OOP and inheritance vlogs))

  • @_________________404
    @_________________404 3 роки тому +4

    I've been told that the main purpose of inheritance is not to "reuse code", rather than that it's purpose is to allow polymorphism. Which means that you can have multiple classes that inherit from a more generic superclass, all objects of these classes could then be used in a code that was programmed to be compatible with the superclass.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      inheritance is just a form of compression. it is more for syntaxtic sugar than anything

    • @_________________404
      @_________________404 2 місяці тому

      ​@@lilyscarlet2584 Ok buddy 💀 Next time maybe read the date before responding to a 3 year old comment. And no. Inheritance is not "compression", what you mean is called composition and is not related to inheritance, rather it is a class acting as a wrapper of another class. Inheritance is not "syntactic sugar", sure, in languages which support static dispatch the call to a class member function can in some cases be directly replaced with it's address at compile time. However as soon as you implement virtual functions and overriding, the memory representation of the object is now not just its data members, but also a pointer to the vtable of this class, which then decides what function will be called. The comment I wrote 3 years ago was more or less right, the point of inheritance is NOT to reuse code, that is just a side effect, rather than that it is used to create a logical hierarchy within your program. Before OOP and inheritance you for example couldn't easily swap a data structure with a more efficient one because everything was hard coded to a one specific data type, now you just have one generic type (e.g. Tree) from which all data structures with the same interface can inherit (e.g. AvlTree, RedBlackTree, ...).
      Don't listen to bs youtube videos like this one as they're often just straight up wrong or inaccurate. To understand why OOP exists and what it does you first need to understand what was used before OOP. The problem with laguages such as C which don't implement OOP by default is that there's no built-in way to associate data (structures of data) with it's behaviour (functions performing actions upon this data). Which resulted in a huge mess of error prone code with pure data structs being passed around functions. Eventually to encapsulate data and it's behaviour people started adding function pointers to their structs (see how this leads to vtables?). This lead to C++ being invented to standardize the various implementations of proto-OOP which over the years people naturally converged to while implementing it manually in C. As you can see OOP is not something that would came "top to bottom", rather it's what the industry itself converged to over many years.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@_________________404 you talk like i dont know these things. c is perfectly fine in most cases the issue is that alot of code bases force you to use these ideologies. you should not be associating data with functions by default. data should be dumb and you have a set of operations on data. watch handmade hero which perfectly demonstrates this.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@_________________404 also the industry is in shambles right now COM is a disaster and the entire web platform. its the patterns people are using thats the problem raii and gc are just patching over a flaw in your code architecture. the correct way to manage memory is to have a combined lifetime and not individual elements. that would alleviate the need for alot of this crap.

    • @_________________404
      @_________________404 2 місяці тому

      @@lilyscarlet2584 Yeah no. You don't know any of this as you don't even know what composition means.

  • @pixelmartyr8532
    @pixelmartyr8532 5 років тому +1

    I'm now using SASS. Now I get why its beneficial. Maintainability!

  • @kyleaca5122
    @kyleaca5122 5 років тому +2

    I took a class on C# this year and it’s the first programming class I’ve ever taken and it wasn’t that hard to learn. (I only know the basics though)

  • @lilyscarlet2584
    @lilyscarlet2584 2 місяці тому

    the problem with oop is objects should never be pre supposed. it should be a natural process. code is procedural and objects arise after the fact. casey muratori coined the term compression oriented which supposes the idea that code should be compressed semantically rather than presupposing objects. that way you have working examples your objects arise from rather than trying to worry about what class things belong to. you all should read it google compression oriented programming its a good article.

  • @caw25sha
    @caw25sha 5 років тому +4

    I agree about excessive use of inheritance. I worked with .NET and C# for many years and everything inherits ultimately from Object but the number of classes in the chain is often ridiculous.
    The idea of OOP actually goes back to the 1950s when it was simulated in non OOP languages, FORTRAN I think. I actually like the Python paradigm where OOP is optional, and even if you do use it it's a fairly liberal version of OOP whereas some languages (cough C# cough) are so paranoid they almost make you feel like a criminal. "How dare you try to use that method, it's PRIVATE."
    Has anybody noticed that most of the mainstream OOP languages were created by Scandinavians? Simula, C++, C#?

    • @aker1993
      @aker1993 Рік тому

      My problem of Java is that you must use OOP which its hard to track with.

  • @ili101
    @ili101 5 років тому +11

    What is your opinion on functional languages like F# (advantages disadvantages vs OOP C#)

    • @siemik
      @siemik 5 років тому

      "Technical reasons often time don't drive market adoption"
      ua-cam.com/video/QlHf8c6Ma7o/v-deo.html

  • @fredflintstone8048
    @fredflintstone8048 5 років тому

    There are many environments we work in that are nothing but structures of objects. Dot net programming for example. Inheritance is integral to developing in that environment.

  • @richardnicholas2957
    @richardnicholas2957 5 років тому +2

    Which is the video describing using interfaces instead of inheritance? I can’t find it on your channel. Thanks.

  • @MrSmith01
    @MrSmith01 5 років тому +4

    @Stefan, can you please comment Fred Brook's quote: "What one programmer can do in one month, two programmers can do in two months"

    • @StefanMischook
      @StefanMischook  5 років тому +1

      Yea ... this is an issue I have dealt with a lot in the past ... and recently! To summaries: adding more programmers, many times, won't speed up the production time. I've found that after you have 3 developers on a project, the law of 'diminishing returns', kicks in viciously. To the point, that I don't have more than 3 on a project.

    • @MrSmith01
      @MrSmith01 5 років тому

      @@StefanMischook Imo this subject deserves a separate video!

    • @caw25sha
      @caw25sha 5 років тому

      That's because they need to spend half their time discussing what needs to be done, how to split the workload and how to get their code to work together.

  • @SaudBako
    @SaudBako 2 роки тому

    I don't think of inheritance as code reuse.
    It's subtyping, and if code is reused, it is a lovely side-effect.
    Like, a book can be a physical book or an eBook.

  • @szeredaiakos
    @szeredaiakos Рік тому

    Polymorphism is by far the most important feature of OOP. But you are not the first one to get it wrong.
    Inheritance as it is, is like ... whatever ... sometimes useful. Encapsulation might be the other most important part.
    Also, I duplicate code all the time. It is mandatory across context boundaries.

    • @TurboXray
      @TurboXray Рік тому +1

      "But you are not the first one to get it wrong."
      One, that's subjective. What's not subjective, and very much objective.. is that the most important part, and fundamental to OO design is the idea of objects themselves; the encapsulation of methods to be closest to the data it needs to interactive with and perform operations on. *Everything* else is just a natural extension of this design concept; interfaces (inheritance), polymorphism (runtime or compile time), etc. But interfaces and polymorphism are not mutually exclusive to OOP.

    • @szeredaiakos
      @szeredaiakos Рік тому

      @@TurboXray Yes, but other paradigms have no issue with encapsulation. Punchcards, for example, have rubber bands and bookmarks. Encapsulation is very important, true, but not specific OOP.
      OOP offers probably the biggest set of tools to manage complexity. The magic comes alive when you have something like DataBase.update({some: data}) and you stop caring about the implementation of update() as long as it returns an "OK". You can have 100s of forms of update for different databases. Can you do that using other paradigms and principles? Yes, obviously. Will it still be maintainable after 10 years... Probably not. In OOP you can have it somewhat maintainable if you put some grease into it. And by maintainable I mostly focus on the ability to completely change the structure beyond the "update" call.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@TurboXray you should never have to think about objects or you are doing it wrong. objects should arise naturally not something that is planned. code is procedural and objects naturally arise as you need later on.

    • @TurboXray
      @TurboXray 2 місяці тому

      @@lilyscarlet2584 Thankyou for the most vague bullshit answer ever hahah. I swear, some peoples' children.. smh.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@TurboXray its not vague. you write your code define your variables and functions then when you need to reuse some data set put it in a struct and pass it around and use shared stack frames.

  • @Jollyprez
    @Jollyprez 5 років тому +2

    If you think structures and procedural coding causes spaghetti code, wait until you start using OOP. I think the biggest problem with OOP are class libraries that try to do too much. Any particular library of the past - going back to Think Class Libraries ( TCL ) - from 1987, through MFC, through CodeWarrior, through Swing, through all kinds of other things - they just made them too generic and code bloat that makes the Hindenburg look like a drug store mylar balloon.

  • @philadams9254
    @philadams9254 5 років тому

    It's just a way of categorizing code. Just like namespaces or filesystem folders.

    • @MrSmith01
      @MrSmith01 5 років тому +3

      you can categorize your code via 'including' files

  • @LukePighetti
    @LukePighetti 5 років тому

    Inheritance for interfaces only!

  • @mikiallen7733
    @mikiallen7733 Рік тому

    so does it mean that it is less secured / if its easily breakable as you mentioned relative to other inheritance-free style of programming ? your input is highly appreciated
    best

    • @StefanMischook
      @StefanMischook  Рік тому

      Not sure what you are asking? Can you restate?

    • @mikiallen7733
      @mikiallen7733 Рік тому

      @@StefanMischook is oop more or less secure as style of coding / programming relative to say any well known functional programming language, which is tends to throw less errors in production environment?

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@mikiallen7733 no. it is not. oop is actually a bad idea that has overcomplicated code bases more than necessary through obfuscation. 99% of the time procedural code is better where you have a logical flow of if/switch statements rather than classes split across multiple files. it is very hard to conceptualize the program as a whole and you often miss redundancies or have more interfaces than necessary making it hard for systems to communicate. google compression oriented programming. it goes in detail about this theory and supposes a better solution.

  • @silversolver7809
    @silversolver7809 5 років тому +7

    Is OOPs the plural?

    • @amirhosseinahmadi3706
      @amirhosseinahmadi3706 5 років тому +3

      Well, OOPs actually means "Object-Oriented Programmings!", which doesn't make sense. So, you should probably say OOP languages instead, as Stef does.

    • @TraceyOsbornHR
      @TraceyOsbornHR 5 років тому +3

      "oops" I see what you did there haha. "oops" I did it again.

    • @maheepthephenom
      @maheepthephenom 5 років тому

      OOPS full form is Object Oriented programming System

  • @cyrusol
    @cyrusol 7 місяців тому

    I've been told by people who earn twice as much money as me that polymorphism would be "exactly the OOP thing we all hate", and why Go's interfaces are so much better than whatever Java does.
    Everything comes full circle. First OOP was great and advocated for by smart people, then dumb people misunderstood it, then smart people critizised it, then it survived and now dumb people continue to "critizise" it.

  • @MiketheCoder
    @MiketheCoder 5 років тому

    Nope. You can search online. OOP originally was for message handling between computers. The guy wanted to mimic networks by having objects send messages to other objects.

  • @4everMatador
    @4everMatador 5 років тому +3

    Who's Down with OOP!?

  • @lukabiskupic4910
    @lukabiskupic4910 5 років тому

    Can I use Symfony framework for small or medium size projects?

  • @Kricen
    @Kricen 5 років тому +1

    In OOP inheritance is the first priority way to do things. It's one of the major ideas of OOP. If you can't for some reason get it, just don't use OOP language, but also don't try to downplay inheritance just because you don't understand it. "Avoid inheritance" is extremely bad advice to give and can in theory hold back people who try to learn OOP.

    • @krztix
      @krztix 5 років тому

      how about you tell the reasons why you are saying that rather than blindly stating your opinion

    • @Kricen
      @Kricen 5 років тому +2

      @@krztix Besides inheritance is not all about "reuse" of code. When I hear that term I'm like yeah, but no... With inheritance you are supposed to organize your code from simple low level classes (more like user defined "types") to more complex ones. You can and should organize your code in all programming styles, but in OOP it's much more important. The funny thing is that when you avoid inheritance in OOP code it's going to make things harder, not easier.

    • @caw25sha
      @caw25sha 5 років тому

      OOP is fundamentally about tying together data and the code which works with that data, which at a practical level involves writing classes which contain both, and then instantiating objects of that class.
      It is often stated that the three core principles of OOP are inheritance, encapsulation and polymorphism. However, it would be possible to design a very useful OOP language without any of those three capabilities. Even in a language which has them you don't have to use them (aside from the fact that the language might implicitly inherit from some ultimate base class).

    • @widearchshark3981
      @widearchshark3981 2 роки тому

      I'm with Paul on this. Just saying "don't use inheritance" is a pretty worthless view without any context imo
      When thinking of a real world example of a good use of inheritance, I always refer back to the java.sql classes. As a programmer, you know what methods you can call on it, regardless of the database provider (Oracle, Sybase etc). Because they all provide their own implementation of the interfaces.
      So it 100% has it's uses in the right situation.

  • @iamreg1965
    @iamreg1965 5 років тому +2

    Like all things in this world, everything in moderation and the application of the best tool for the job.
    The very basics of OOP, inheritance, encapsulation and polymorphism are all you really need. Everything else is just trendy bullshit, as the overuse of patterns and use of ORM's have shown.
    A well written program, in a language that allows it, will have elements of procedural (even modular), OOP and functional dotted through out. PHP is great for this.
    In the MVC paradigm, procedural code would normally dominate the controller scripts and the model will consist of one abstract class and many classes that derive the basic functionality from that, especially when writing database applications. Design the database first and add the business rules in the model on a per table basis.
    Functional elements are extremely handy for filtering, mapping and reducing data whilst keeping the original lists (arrays) intact.
    The view will invariably be HTML templates that accept data from the model.
    Things such as games programming are another kettle of fish entirely and I have no interest in those particularly. My knowledge of physics and calculus is not strong enough.

  • @ovidiuc4
    @ovidiuc4 5 років тому +3

    was that "Bob's your uncle"? ha ha

    • @ovidiuc4
      @ovidiuc4 5 років тому +1

      @Peter Mortensen Thanks, I didn't know that expression, I thought he was referring to Robert C. Martin :)

  • @laughingvampire7555
    @laughingvampire7555 Рік тому

    and with OO you can get into Macarrones code

  • @stewiegriffin6503
    @stewiegriffin6503 2 роки тому

    you did not answer the question... you can write perfectly clean code with procedural language... OOP has todo with compiling external libs

  • @zebnat
    @zebnat 5 років тому

    We all made the mistake of inheriting everything creating a hierarchy mess then we learned about object composition.

  • @andilerodney7215
    @andilerodney7215 5 років тому

    More of these nuggets uncle Stef......i like.

  • @theteknologist9574
    @theteknologist9574 5 років тому +1

    When it comes to cheese and bacon; why not choose both?

  • @Acid31337
    @Acid31337 3 роки тому

    People confuse benefits of languages like Java with benefits of OOP.
    No, code in Pascal or C is spaghetti not because its lack of OOP.
    There are no garbage collection, no built-in data types besides array of bytes, no rich libraries, no stacktraces when program crashes.
    You don't understand that there was a great problem even to return something from function bigger than single number.
    It also was different kind of problems and different IDEs and hardware...
    There was ton things that made life easier and code prettier.
    Not OOP.
    Just try write code today in modern language without OOP. It would much easier, because you will not face any problem you have told will be without OOP.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      garbage collection is unnecessary. if you need it you are doing your allocators wrong. watch handmade hero if you want to know how to write c proper and not have a need for any of that. all of that stuff is just patching over a flaw in your code architecture.

  • @mrmack678
    @mrmack678 5 років тому +1

    how good is a Cs degree to get into AI

    • @immortalnub
      @immortalnub 5 років тому +1

      Don't bother. I got a CS degree, didn't learn shit, and I cannot find a job.
      The professors will either just read off of slides like a high schooler or jump around in a labyrinth of code. UA-camrs are far better teachers. I would say that college is nice if you need direction, but go to community college for that.

    • @mrmack678
      @mrmack678 5 років тому +1

      you two are right and yes i m taking courses to improve my programming skills and later to dive into ML but in my country its really hard to get even an interview for a job without a degree
      to most part of me i do believe that self learnings and online resources are much better than spending 4 years at a university

    • @immortalnub
      @immortalnub 5 років тому

      @@mrmack678 Keep your programming assignments for reference. I regret not keeping mine.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@immortalnub handmade hero is a good series on youtube. it shows how to build a complete game from scratch in c++ and goes in depth on how things work.

  • @zoommair
    @zoommair 5 років тому

    Great explanation! Could you link us the Inheritance video?

  • @kayakMike1000
    @kayakMike1000 2 роки тому

    Is it REALLY better organized? I dunno, man... Modularity you speak of in Classes could be emulated pretty well with opaque pointers in C.
    You do not need "classes" to break up your programs into reasonably sized chunks.

  • @phee3D
    @phee3D 5 років тому

    hey stefan, you always say "learning 20 mins a day 5 days a week is better than learning 100 minutes a day once a week" but what about learning and practicing 3-5 hours a day? do you think that's a healthy amount of time per day and would an average brain retain the knowledge at this pace? provided that I keep going back to the basics often to get some refreshers as i inevitably forget some stuff

    • @AnDrU085
      @AnDrU085 5 років тому

      Thats what i do. Try to dedícate between 4 and 6 hours a Day if i can. If im stuck with something i Just make a pause and do some other thing, play games, etc. Then you came back with a fresh mind.

  • @bigpod
    @bigpod 3 роки тому

    i dont think i wrote a single interface or inheritance outside of educational environment

  • @elbozo5723
    @elbozo5723 3 роки тому

    y’all don’t stay for too long he gotta go to lunch

  • @SajeelCodes
    @SajeelCodes 5 років тому +20

    OOP was actually invented to confuse the new programmers.
    Lol

    • @SajeelCodes
      @SajeelCodes 5 років тому +1

      @@lukevincent4397 can you tell me? What is meaning of LMAO? I have seen this much but don't know what does it mean

    • @jeffreysoto4833
      @jeffreysoto4833 5 років тому +1

      @@SajeelCodes lol = lmao = lmfao = rofl

    • @SajeelCodes
      @SajeelCodes 5 років тому +1

      @@lukevincent4397 ohk

    • @jsceo
      @jsceo 5 років тому +1

      what is hard about oop? never get it

    • @SajeelCodes
      @SajeelCodes 5 років тому +1

      @@jsceo hard thing is the confusion of beginner programmers when just starting out

  • @tanushsathiyaseelan9428
    @tanushsathiyaseelan9428 4 роки тому

    Watch it on 4x

  • @toddboothbee1361
    @toddboothbee1361 5 років тому

    Did you have a wedge of bacon cheese for lunch?

  • @mrswolls
    @mrswolls 5 років тому

    Looking healthy your face looks much leaner

  • @PrivateSi
    @PrivateSi 5 років тому

    Packaging..... The real world is so overloaded with wasteful packaging the virtual brainz followed suit..... How many layers of packaging before we even dig out the code... and then we get to the guts and find loads more boxes full of boxes full of different sweets in different wrappers.... Truly horrible in so many ways...

  • @NintendoGamer789
    @NintendoGamer789 5 років тому

    OOPsie daisy

  • @MR-gold-VR-b6j
    @MR-gold-VR-b6j 5 років тому

    Cmon man... cheese all day everyday.

  • @7p386
    @7p386 5 років тому

    Sksksksksksksks and i oop

  • @howardthealienalien2494
    @howardthealienalien2494 5 років тому

    The meme

  • @cd78
    @cd78 5 років тому +4

    OOP is an overly abstracted mess.....

    • @aoeu256
      @aoeu256 5 років тому +2

      OOP has its uses, but Java & C# are horrible languages IMO. Dynamic languages like Ruby, Python, SmallTalk don't have all of the complexities that require factories and all have some sort of form of "closures". Instead of using objects you can use functions with their closure property as long as your object only has only a single method, and you can put data inside the function (since a function is an object in true OOP languages) for static variables that should be shared between all function calls.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@aoeu256 oop is always bad. objects arent bad but orienting around them is. read compression oriented programming by casey muratori. its on google search

  • @fludeo1307
    @fludeo1307 2 роки тому

    try to scale a project without OOP , you can not. try to make a small project with OOP you can but is overkill.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      scaling does not require oop. you just need to get better at programming.

    • @fludeo1307
      @fludeo1307 2 місяці тому

      @@lilyscarlet2584 that is what a person who only write scripts says.

    • @lilyscarlet2584
      @lilyscarlet2584 2 місяці тому

      @@fludeo1307 or c

  • @4n0n25
    @4n0n25 5 років тому

    Yeah I mean nobody needs it lets just put everything in one main function😂😂

  • @immortalnub
    @immortalnub 5 років тому +1

    Oop was invented because people got sick of functional xD

  • @laughingvampire7555
    @laughingvampire7555 Рік тому

    tell me a single feature of any programming language that is native to OO that hasn't been discredited or discarded or replaced by something better? NONE!!! ALL OO is history and that is why you have none of those features in Rust. Rust is safe and is 99.99% the performance of C/C++ so we are paying safety with 0.01% of performance, is worth it.

  • @alexkfridges
    @alexkfridges 2 роки тому

    this video is utterly devoid of content

  • @Bm23CC
    @Bm23CC 5 років тому

    GOTO