DEV Community

Cover image for What was the hardest concept for you to grasp when learning Object-Oriented Programming?
Erik
Erik

Posted on

What was the hardest concept for you to grasp when learning Object-Oriented Programming?

I would say about 99% of developers use OOP in their day-to-day programming and perhaps even a higher percentage than that learn OOP at the very least.

I'm curious to see if there is a concept or idea specific to OOP that many people agree was hard for them to learn at first.

For me, understanding the difference between class variables/methods and instance variables/methods was a bit of stumbling block to me. I used to not understand why you'd want to make a method static.

How about you? When you learned OOP or if you're currently learning it, what concepts did/do you find most challenging to understand?

Top comments (28)

Collapse
 
theowlsden profile image
Shaquil Maria

I think it's the interfaces for me. I thought initially that interfaces where the same as classes and it took me a while to understand their uses. Besides that, the 4 pillars was a struggle too in the beginning. The easiest concept for me was objects😅.

Collapse
 
erikwhiting88 profile image
Erik

the 4 pillars? I'm not familiar with this

Collapse
 
theowlsden profile image
Shaquil Maria

Yes, Abstraction, Encapsulation, Inheritance and Polymorphism.

Thread Thread
 
erikwhiting88 profile image
Erik

Ooh those, thank you!

Thread Thread
 
theowlsden profile image
Shaquil Maria

You're welcome!

Thread Thread
 
gaurang847 profile image
Gaurang

Oh yes! Inheritance was alright. But Abstraction, Encapsulation, and Polymorphism!
It took a really long time for me to understand what Abstraction and Encapsulation mean and how they're different. And a lot more, to understand what Polymorphism is.

Also, it always surprises me how many people have confusion with interfaces.
I know a lot of people who don't have much experience with OOP and they think that interface is something that allows multiple-inheritance in Java. That's what we're taught at colleges where I live.
Was it the same with you?

Btw I wrote an article on interfaces. I'd love to hear your thoughts on it.

Collapse
 
sqlrob profile image
Robert Myers

For me, recursion was the issue when trying to do functional programming. I generally tried to eliminate it in my procedural / OOP code and it was just breaking my brain to get it right in functional where it's practically required.

Collapse
 
xtofl profile image
xtofl

It took me 10 years and 3 to 4 exploded class hierarchies to realize that inheritance is probably not what you need to promote code reuse.

I wonder why they keep teaching that. Code reuse => functions (or object aggregation, at best!)

Collapse
 
ssimontis profile image
Scott Simontis

Honestly for me, it was learning that a lot of projects don't do a great job with OOP. I think a lot of times we embark on projects without being able to represent the domain with enough knowledge to create an accurate representation of systems, resulting in fun code you might have seeing before like AbstractLoggerFactoryFactory :D

Collapse
 
amine250 profile image
Amine Zaine

While learning Java, I did struggle to differentiate between inheritance and polymorphism.

Collapse
 
ratrateroo profile image
ratrateroo

If i understand it right if you apply oop, there are oop best practices or design patterns. Am i correct?

Collapse
 
erikwhiting88 profile image
Erik

Yes, there are best practices for OOP, but there are best practices for lots of things.

Design patterns are not necessarily OOP-specific as you can have functional programming design patterns too (like the Failure Monad for example).

In an OOP context, a design pattern is a specific relationship between one or more classes to get some kind of desired behavior; you don't technically need to know design patterns to know OOP.

Collapse
 
ratrateroo profile image
ratrateroo

In real world scenario in oop as of now do often use common design patterns like singleton and other stuff or for complex problems you just do freestyle?

Thread Thread
 
erikwhiting88 profile image
Erik

a little bit of both. Sometimes, problems are so common that we just know we're going to need a singleton (or factory, or observer, etc), so that's what we build.

Other times, problems aren't so obvious and the solution we come up with starts to look like a pattern sometimes.

You don't need to worry too much about design patterns when you're first learning OOP. Get more comfortable with OOP concepts like polymorphism and inheritance, then learn about writing SOLID code. After that, learning design patterns will be really easy.

Thread Thread
 
ratrateroo profile image
ratrateroo

Thank you for sharing your knowledge im starting to see a bigger picture now. I studied oop with java few years ago and that knowledge helped me a lot when i started javascript. From then on i always think in oop.😃

Thread Thread
 
erikwhiting88 profile image
Erik

You're welcome, feel free to ask any questions, I'm here to help!

Collapse
 
consciousness_dev profile image
Ario Setiawan

stay away from over engineered.

Collapse
 
erikwhiting88 profile image
Erik

I struggle with this every day of my career lol

Collapse
 
ender_minyard profile image
ender minyard

99%?

Collapse
 
erikwhiting88 profile image
Erik

I doubt embedded programmers use OOP

Collapse
 
kzzm profile image
Kris M.

Incorrect. Embedded devices that require higher processing power use embedded Linux and C++. A basic example is abstraction of HW layers when retrieving data.

Thread Thread
 
erikwhiting88 profile image
Erik

cool, I had no idea

Collapse
 
drhyde profile image
David Cantrell

Coming from a mostly assembler background at the time I found it very hard to use, just because I couldn't see exactly what it was doing.

Collapse
 
drhyde profile image
David Cantrell

If anyone is struggling to wrap their head around OO programming, I recommend the first edition of Java In A Nutshell. It is long out of print, and the Java content is very out of date - to the extent that some of it is just plain wrong now - but the introductory chapters on what OO programming is are excellent. Later editions don't do anything like as good a job of this.

Collapse
 
fagnerbrack profile image
Fagner Brack

Coupling and cohesion. We use those concepts everyday in the real world but initially fail to use in OOP. In fact it's the same in every paradigm.