I find object oriented programming confusing and abstract how do i get better at it?

I find object oriented programming confusing and abstract how do i get better at it??
any books,videos stories etc

Hi @prak3429!

Since you just started the Javascript section a short time ago it might be that you are struggling with programming in general which is totally normal. Is this your first programming language?

Are you learning OOP through JavaScript? If so, I would suggest using another traditional language like Java or C# if you’re trying to learn OOP

Javascript is a weird love child as it uses both functional and object oriented programming. Prototypal inheritance is just not a good model to learn as a beginner as it uses concepts that addresses the issues with OOP.

+1 on @jwilkins.oboe says, are you just starting? Because if that’s the case, I wouldn’t worry too much at the minute and get basics (syntax, variables, loops etc) down pat first

If it’s not the case, then it’s a fairly big subject and JS quite possibly isn’t the ideal language to get core practical principles down. (edit: heh, just saw @DanStockham post an answer while I’m typing this that mentions that)

Anyway, this book is pretty excellent on practical OO imo, I’d recommend it:

It uses a pure OO language (Ruby) to describe the concepts, but the concepts are transferable

2 Likes

yes it is my first programming language I am learning. Have done c programming in college for data structures but that was ages ago. I have always found oops concepts confusing. maybe I have built it in my mind. I also want to know when is the right time to get into oops. Is it after using a lot of functions and understanding the problems that it causes.

I personally wouldn’t worry about OOP right now. I think it is just best to brush up on the basics of programming and create a healthy foundation to start off with.

Yeah JavaScript is definitely weird but focus on fundamentals first because that is in every language.

After that you can explore @DanCouper’s suggestion.

@prak3429 Learning OOP right out of the bat on your first programming language is hard. This is because you might not even know the language you are trying to do OOP in. Or you don’t really understand OOP and the concepts of it. I would get comfortable with the language at hand before I jumped deep into OOP. Also another thing, JS isn’t the best for OOP. If this is something you really want try something like JAVA or C#! Happy Coding! :smile:

I want to get into web development right now. So learning html, CSS and JavaScript. My language of choice is JavaScript(for web development).If I can get away without learning oops into web development I am a happy guy. About JAVA
that will be way into future after getting job in web development.

Ruby wouldn’t bring you that far away from web development, Ruby on Rails is used for back-end

Keep it in mind after you do some back-end projects with NodeJS

@prak3429 If you want the Web-Development route then for sure use JavaScript. I would get a hold of syntax and using the language itself before I really tried to understand OOP. You will probably want to at least understand the concept of it. Good to learn later on in your Dev journey! :smile:

My suggestion wasn’t really specific to a language by the way – the book I think is good (and it’s just my opinion, don’t take it as gospel!) happens to use Ruby, but it’s more about how OO code should be designed.

Here’s a JS-specific book (I found it really useful, but it’s quite technical and a bit dry rather than being totally practical):

OO isn’t a scary thing by the way, it’s incredibly common, but I think the way it’s explained to beginners leaves a lot to be desired.

At core, all it is is a way of structuring parts of your code by packaging up some data and the functions that work on that data into one thing (an object).*

Like in JavaScript an Array is an object that has some data (properties stored under integer keys and a length) and it has some functions that operate on that data (push, pop, shift, reverse, map etc).

You create a new instance of an Array object, then you can use the functions attached to it to operate on that data.

Lots and lots and lots of beginner OO stuff (of the form Dog is a type of Animal, or Car is a type of Vehicle) is really confusing IME as it misses most of the practical uses of OO. Those sort of explanations are kinda easy to understand on a surface level because it makes objects look like real life things, but they aren’t and imo I think it’s actively harmful (certainly I found it extremely confusing, for me it overcomplicated what are actually pretty basic concepts).

Another genre of beginner OO stuff has a pathological focus on patterns and things like SOLID. Which are there to deal with issues you will likely encounter after you’ve written quite a bit of pure OO code – they’re optimisation techniques and again they’re super confusing when you’re learning things as a beginner.


* Compare to functional programming, where you may have some data, and you write functions to operate on that data, the two things aren’t attached (you need to pass the data into the functions, it isn’t part of the same thing).

2 Likes