Using OOP Language Features, Does Not Mean A Project Is Using OOP Correctly. The Principles Come First.
As a famous dude once said, “the rumors of my demise have been greatly exaggerated.” I think the same holds true for OOP. Developers are piling on in their disdain for OOP. OOP is a giant mistake! Paradigm X is better. So here’s a mixed list of facts and nonsense claims about OOP.
You Don’t Know OOP
When OOP is taught it usually starts with conceptual and abstract explanations. OOP is an extremely complex topic so starting with the technical details or code samples would be hard for anyone to digest. The problem is that since we are humans we can make all sorts of assumptions or draw incorrect conclusions based on high level explanations.
This is one of the most digestible technically accurate explanations of OOP I’ve ever seen, https://www.freecodecamp.org/news/object-oriented-programming-concepts-21bb035f7260/. I won’t even attempt to do it better because I cannot. Please review even if you think you know OOP.
The reason I’m suggesting you review it is because I recently watched a Youtuber video, with over a million views, and was surprised to see their explanation for Encapsulation. Basically this Youtuber explained Encapsulation’s main purpose as being the grouping of related object data. This is unfortunately not correct. Encapsulation’s main purpose is access control of member data. That is to hide member data so that it is strictly under the control of the class that it belongs to.
My point is this, there is a lot of incorrectly implemented OOP code out there, because developers misunderstand it. Just like there’s a lot of incorrectly implemented code in Functional Programming and just about any other major paradigm. OOP is an easy target because it is so ubiquitous, not because its bad.
Your Language Actually Does Not Do OOP
Let me lay it out flatly if you’re dissatisfied with the results of OOP, it may be that your chosen language does not really support it. Doh! I’ll say it another way if your language does not support static typing, access modifiers, and interfaces (or abstract classes), it can only mimic OOP and does not truly support it.
So then in the end what do you get? A lot of very clever complex code that may achieve some adherence to OOP principles but at what cost?
OOP Is Too Hard
My programming language supports OOP but it’s too hard. News flash programming is hard. It’s really really hard to do well. But that’s why we get paid the big bucks. Going to work every morning is hard. Working out is hard. But they all have their benefits when done properly. Trying to do anything well is hard. Don’t conflate poor OOP implementations with the idea that OOP sucks.
If you don’t know the tool you’re using you will use it poorly. This is just as true for programming paradigms as it is for languages.
There’s lots of different programming paradigms. For example I find Rust’s Trait based programming to be quite promising. It’s not at all OOP in my opinion. But having said that it has huge potential, both the language and the design style. As Rust develops further and more software is built using it, this style of programming may become the preferred way of coding large apps. However as of right now OOP is still king. It has the sophisticated tooling, the language support, and the developer mind share and experience. I suspect OOP will continue to be used for decades to come.
As always if you like helping other devs try DzHaven.com