Object Oriented Programming Explained in a Nutshell

preview_player
Показать описание
Object Oriented Programming Explained. What are the core concepts and principles? In this short video you will get a grasp of them.

Object Oriented Programming (OOP) is a very popular programming paradigm and top companies look for people with strong knowledge of the basics of OOP. In this video I cover the context of where OOP comes from, the basic naming conventions and principles that rule OOP, one of the core concepts required in many technical interviews.

Hope you enjoy the video! Don't forget to comment, like, share and subscribe :)

Recommended resources:
Рекомендации по теме
Комментарии
Автор

Been trying to code web FE with JS for two years and it's the first time I can have some grasp of what OOP and Class mean. All thanks to your 6 mins vid. Buen trabajo!

FacundoTroitero
Автор

My mind is blown. Still really not sure what is going on, but I love the whole drawing component to this. Great job with the explanation! Watched your whole video to support!

exploreaswego
Автор

Very clean and straightforward, keep the good work!

jesuskraisnik
Автор

Hello Christian, I think that in the example of the relationship (aggregation) between the car and the wheel classes, the hexagone must be in the car side

anask
Автор

Picture a boat in your head. Got it? Okay, great!

INHERITANCE

What kind of boat did you picture in your head? Is it a 1 person sunfish? A yacht? A submarine even!? All of those are examples of boats. So say we want to write a program that will have a sunfish, a yacht, and a submarine in it.

We could do this a few ways. We'd create classes for a sunfish and a yacht and a submarine. Sunfishes, yachts, and submarines all have attributes that they share since they are boats. They have a top speed. They have weight. They have maximum passenger counts. In each of our classes we could define these variables, but that means we'd write the same line of code over and over. In the sunfish class we'd create a variable called top speed, then in the yacht class we'd create a variable also called top speed. We'd do the same thing for the submarine. Then we'd have to do the same thing for weight and passengers. Basically, we'd write a lot of code!

INSTEAD, we'll create a class called "BOAT" where we will define our variables to hold weight and top speed and passenger limits. Then when we create our yacht and our sunfish classes, we'll tell those classes to inherit from the "BOAT" class. What this means is that they will automatically have variables defined in the BOAT class in them already! If we use this method, we can create all different types of boats simply by creating new classes and inheriting from the base class of "BOAT" without having to write all new code! We could make ocean liners, jet skis, etc.

ENCAPSULATION

This one is REALLY simple. This means that an object that exists in your program should only be able to control itself and nothing else unless EXPRESSLY stated. Boat A should be able to tell itself to propel through the water but it shouldn't be able to control what Boat B does. Boat B has to take care of itself. If there is a piece of code in the BOAT class that tells itself to move we can either make it private or public (there are others but don't worry about it for now). Private means that only the Boat can tell itself to move. Public means that ANY object can tell that boat to move. Boat A telling Boat B to move doesn't make sense. Boat B should have sole control over itself and nothing else!

Polymorphism

Say we have a program that is simulating a lot of different boats. At the beginning of the program all the boats are stationary and when we click the start button all the boats in the water start moving. There are many different types of boats in our simulation: yachts, submarines, sunfishes, ocean-liners, etc. To have all the boats "go" when the user clicks the start button we can write this two ways:

One would be to tell each object individually to "go" which would look something like this.

Sunfish -> Go!

Ocean-Liner -> Go!

Submarine -> Go!

YachtA -> Go!

YachtB -> Go!

Notice that we have two yachts. I have to call those yachts individually and tell them to go. What if our program has hundreds or THOUSANDS of boats. That's a lot of code!!!

Instead, we use POLYMORPHISM to make things much simpler! Remember from inheritance, yachts, submarines, sunfishes, ocean-liners, they are all boats! Our code to tell all the boats to move could be something like this:

Get a list of all the objects that inherit from the base class BOAT.

Use a loop to go through each boat in that list and tell it to go!

In this case, we're telling each boat to go based on them all being a boat. We don't care what type of boat it is. If it's a boat then we tell it to go!

RR-etzp
Автор

awesome.... each and everything is valuable and it is a million dollar lecture

DebasmitSamal
Автор

Well explained and a good help for new and experienced devs

beeldy
Автор

0:39 Is it logical paradigm as well as procedure paradigm sir?

adipurnomo
Автор

Amazing video! Short and clear!
What software did you use to draw your diagrams?

dr_itchy
Автор

Abstraction in oops means hiding the complexity of the code ryt ? I didn't understood your explanation

harinderchoudhary
Автор

Your study guide link is not working.

jennifermcginniss
Автор

hi frd im your recent like ...💖💖💖AIG DESIGNERS.💖💖💖...your videos are realy awsome...stay connect my friend....💖💖💖
..

AADHIRAINTERIORS
visit shbcf.ru