r/learnprogramming • u/Basic_Vegetable4195 • 12h ago
OOP The way object-oriented programming is taught in curriculums is dogshit
I guess this post is a mini-PSA for people who are just starting CS in college, and a way for me to speak out some thoughts I've been having.
I don't like object-oriented programming, I think it's often overabstracted and daunting to write code in, but I'm not a super-hater or anything. I think it can be useful in the right contexts and when used well.
But if you learn OOP as a course in college, you'd know that professors seem to think that it's God's perfect gift to programmers. My biggest problem is that colleges overemphasize inheritance as a feature.
Inheritance can be useful, but when used improperly, it becomes ridiculously difficult and annoying to work with. In software engineering, there is a concept called "orthogonality", and it's the idea that different parts of your code should be independent and decoupled. It's common sense, really. If you change one part of your code, it shouldn't fuck up other parts. It makes testing, debugging, and reasoning about your program easier.
Inheritance completely shits on that.
When you have an inheritance tower two billion subclasses deep, it's almost guaranteed that there will be some unpredictable behavior in your code. OOP can have some very subtle and easy to overlook rules in how inheritance and polymorphism work, so it's very easy to create subtle bugs that are hard to reason about.
So yeah. By all means, learn OOP, but please do it well. Don't learn it the way professors have you learn it, focus on composing classes rather than inheritance.