Probably the most useful 10 min of learning OOP so far. I never really understood those 4 principles and now they seem a) sorta easy (both to use and memorize) and b) I was already applying some of them without knowing. Amazing! Thank you kindly
You haven't been to the moon, yet. If you should ever try OOP in reality you will be disappointed though. It does not do any of the things it promises well. The problem lies in the fact that data dependencies in real world applications have a graph structure (a tree, if you are lucky). OOP is not very good at taking care of that and if you try to use inheritance, in particular, then you will find that you are hard-coding assumptions about that data dependency that may change during the evolution of your project, which will make frequent refactoring necessary. There are better ways of dealing with that problem. Try to learn to think about programs as state machines with as few distinct states as possible. Rather than encapsulating data, control state change. Each state change should be associated with a well defined change of the data. That way your data structures can change freely as the project matures, but the basic flow of the program (as seen by both the user and the programmer) stays the same.
I am delighted to help. You will hear a lot of negativity about OOP but please bear in mind that it aims to facilitate collaboration and scalability. :)KD
OOP was THE hot topic when I was a developer. Took me a little study to understand its foundational concepts. I couldn’t understand why everyone seemed to think that it was THE way to create programs. Sanity eventually prevailed, as it usually does, and it certainly has its place, but if your design does not utilize inheritance and polymorphism, then use another language type. Don’t force a particular model into an OOP design just because your CompSci instructor loved Java.
I learned OOP from a video that Philippe Kahn made about the subject when Borland’s Turbo Pascal first introduced this new way of programming. It took awhile to understand and master the concepts, but after that, I absolutely loved it and it made large, complicated projects so much more manageable. The ability to start with a base class and do inheritance was extremely powerful. It literally enabled us to program our products in a fraction of the time and with fewer programmers than the old spaghetti code ways of coding.
I agree. It's a great way to manage large projects. I worked for a number of years in software development (albeit as an educator) and OOP allowed hundreds of developers, in different parts of the world, with a range of skills, to work together effectively on very complex applications. :)KD
Finally a concise and clear explanation about these fundamentals. The amount of interchangeable terms (that still have different meaning(s) under certain context's) is ridiculous - and near impossible to find a video/documentation that explains them without convolution.
You had a very clear and nice way to describe those concepts. But in my opinion, Polymorphism is much more than just the ability to override a method from a super class. Polymorphism is the ability of an object to take on many forms. Thanks for a great video
You welcome. Polymorphism catches a lot of people out - so I wanted to keep it very simple for now. One day I will come up with some other examples which make the point that it does indeed literally mean 'many forms' :)KD
Yes. The video leads one to believe that polymorphism is only used in subclasses to override superclass methods. Duck typing (not always available, depends on the language) is the more general and useful case where the same message name can be used in classes that have no common superclass.
I'm very very impressed. I'm not a strict Java begineer, but I did need to find videos/resources to understand these OOP concepts better. I had watched already 5-10 sources, but yours is just the most clear. Concise, and clear. Very impressive. Thanks!
Thank you so much, this was very helpful! My professor and textbook did such a poor job of explaining these basics that I felt like I was falling behind.
This is a new concept fo me and I've watched about a dozen of videos but should have started with this one. The clarity and simplicity of the explanation are unmatched. Thank you!
Wow this is the best explanation Ive seen!!! I have atechnical interview tomorrow and I only know data and sql and not much about OOP in debt. THANK YOU for this great educational content. Today they always jump to Python or the programming name directly, but I miss the real theory and thinking.
Will add to the pile of positive comments here and say this is the most concise, informative, and accessible video on the subject I've seen. great work
Thank you, I have watched this video about 5 times over the last week, every time... I grasp the concept you are talking about a little more, and then understand another smaller detail you mention. I really, really like that whilst explaining, you animate very clear, sensible, logical examples as you go, so I can see what you mean as you are explaining it. I still need to watch it many more times fully, but it is clever, logical, makes sense and is super interesting. Thank you for taking all the time to put this together.. your time a few years ago, has helped nearly half a million people... or if like me.. helped 100k people 5x. ha ha
Great breakdown/explanation of the OOP concept. OOP is one of my favorite areas in computer science/programming applications. Its not as an intimidating as it sounds. Next: I would love to see a short video on the application of these four OOP constructs in terms of their application; write a simple program that demonstrates each of the four areas. Thanks.
Great job! Thanks for saying what a class is really. The word template was close to meaningless to me. But saying that a class is "code written by a programmer" is far more precise and meaningful to me.
Thank you for your brilliant explaination. I now know why OOP does not work for my type of programming. I deal with mathematical processes and not objects. Data goes in, formulas are applied, results come out, results are stored or presented. OOP fits database problems. My programming fit the chsos of a spreadsheet.
5:51 "An Employee is *also* a person" The way this is said with such a straight face, I thought it was a set up for a joke, like: "An Employee is *also* a person, unless they work at a Law-Firm."
Hmm... now terms encapsulation and API seem to be the same or at least very similar.. would you agree? Encapsulation is usually used when we talk about OOP, and API is usually used more broadly - not explicitly connected with OOP. You also mentioned data hiding, another term that is usually mixed with encapsulation. All I'm saying is that there are very similar terms that are connected with each other. Anyway, beautiful video. One of the greatest channels. Thanks for creating this content for free!
Thank you, and you are most welcome. I can see where you're coming from. An API is a way that a programmer can utilise the code someone else has written without being able to see 'under the bonnet'. In that sense, the API code is encapsulated. The most used definition of encapsulation is "the hiding of data and complexity", but it is also a way that an organisation can protect their intellectual property, that is, their source code. Many people confuse encapsulation with abstraction. Abstraction is to "ignore detail". If you are a studying for an exam and might get asked questions about OOP, then the definitions are important.
@@ComputerScienceLessons OOP provides abstraction, all right, but it provides the wrong abstraction for the overwhelming majority of problems because the "functions act mostly on data inside their own class" assumption is usually not even remotely correct. As soon as there are strong dependencies between data elements in different classes (and there almost always are), OOP becomes an unsolvable puzzle.
The part on inheritance has some potential theoretical issues, but it is after all just an introduction. Generally speaking, inheritance should be used to model "is a special kind of" relationship, and should not be used to model as "is a role played by a" relationship. An employee is not a special type of person, it is a role played by a person. Same goes for Customer: that is not a special type of person, it is a role played by a person. For example, Alice could be an Employee of Walmart, but she could also shop there so could also be a Customer of Walmart. So if you are creating an object for Alice, would you create an instance of Employee or Customer? On the other hand, a dog "is a special kind of" animal, not a role played by an animal; and a fish "is a special kind of animal", not a role played by an animal. A dog cannot simultaneously be a fish, nor can a dog quit being a dog and become a fish; and a fish cannot simultaneously be a dog, nor can a fish quite being a fish and become a dog. So here inheritance does not suffer from the above problem. If you have a pet dog named Wolfy or Max, there is no ambiguity in what class you would use to create an instance for your pet: it would be a dog.
I see what you mean. However, the context of the system you are designing is important. If for example I was building a payroll system, and Alice was an employee, it is probably neither here nor there if she is also a customer (staff discounts excepted). :)KD
"So if you are creating an object for Alice, would you create an instance of Employee or Customer?". what is the answer? u shouldn't create 2 instances should u?
I once was doing telephone interviews for senior developer positions at SAGE (the accounting software company). I asked the candidate if he could give me an explanation of what polymorphism was and an example of where he’d used it. He accused me of making the term up 🤔. “What the bloody hell is that” or words to that effect. He didn’t get invited to a face to face interview.
I have seen many as I keep forgetting it but this stands out. Thank you for the creators and the presenter such a clarity and use of just enough visuals. Esp the take away is synonyms which are used, that trips me, After this hopefully not anymore.
this has been the best video i have ever seen - great analogies and loved how you included all the different terms used to describe the same thing - new sub
i wish i watched this at the start of my OOP subject, the way you explained it made it so much easier to understand, the examples you used and visual effects really helped also. edit: I also remember watching your Dijkstra's Shortest path video back in highschool, that was also amazing.
Haha I remember having trouble understanding this. Then I went on to learn SQL and database design (entity relationship design and cardinality), learned how to use Terraform modules and I created Terraform modules likewise with Ansible, and finally back to studying Python again. Personally, the other stuff made me understand and appreciate object oriented programming a bit more.
Why this one's understandable I'm not sure. But over the many years of listening to vlogs on OOP .... this one seems to make the most ( simple ) understanding for me.
Thanks for this. I've learned it over my career but this is a great view. I had the worst intro to this from a UCSD professor. He wouldn't have made it in the real world.
thanks for your effort, it was clear, but i think that in the abstraction part, you explained this latter concept just from the developer side (focusing on the neccessary data for the developed program) and not from the software user side (using the program without a need to know what's in the background).
Very clear description! Worth pointing out that there is more to OOP than just class-based programming. As a developer with some experiences I feel that there is too much focus on classes rather than objects and how they interact.
Hi, I just started learning to code in java, I've learned up the basic syntax, now learning the OOP concepts. Can you elaborate on your point? I myself thought OOP is only about creating classes and objects associate with them. .
@@Regr310 It is about how to using the OOP tools to model behavior and data in the forms of objects interacting withe each other - where the classes are templates for objects. This is often overlooked in any basic programming course which teaches you the language and not the paradigm or software modeling.
Sir kindly make videos on all subjects of Computer Sci.Specialy on OOP,s concepts,Computer Architecture and On Operating system.Sir your teaching method is owasame.....you cleared my all doubts related to opp,s basic concepts.Thanks
another fundamental concept not discussed often enough: "composition" - it models the relationship between two or more classes in such a way that a class can be said to "contain" (reference) other classes (as data, encapsulated or not), and represents a "has-a" relationship, as opposed to its antithesis, the "is-a" relationship (inheritance). example: a house has one or more rooms, and each of those have doorways, and may or may not have windows. a cell consists of a membrane, mitochondria, nucleus and dna, etc.
Yes, that's cool.. until you meet dogClass. Dogs have an owner and a walker and the owner is not always the walker. The owner does hire the walker, though. So now you have a non-tree like dependency (it's a cyclical graph) where both the owner and the walker can walk the dog, but the owner has to pay the walker in addition, even though owner and walker perform the same function on dog. In addition, when something goes wrong with the walking, dog has to throw different errors depending on who did the walking and it very soon becomes a jumbled mess. This is all fairly simple in a procedural style, especially using state machines and switch statements at runtime, but trying to delineate even such a simple triple relationship in a class hierarchy leaves a jumbled mess that is almost unreadable for anybody who thinks rationally about walking a dog. ;-)