Yep. After reading all the examples, I know that all vehicles have wheels, but cars have a variable number of doors, whereas motorcycles don't have any.
Now, for step two, I just need to find a large automotive manufacturer that's completely brand new to the idea of software, and I'll be able to nail that interview...
It’s a funny joke. But there are some very real difficulties with classical inheritance, the main one being “what is a class”? If a class if an object, then it must necessarily have a class of it’s own, so what’s the class of Class? Logically, the class of Class is Class, so you have a circular inheritance loop at the top of your hierarchy.
Alternately you can say that a class is not an object, it is syntax. This creates a whole other set of problems. Where do you put your static methods? How do you manipulate classes? You need a whole introspection API.
JavaScript sidesteps all these issues with prototypical inheritance, which is way simpler.
This is why i hated C++ when it came out (yes im that old) i came from c, forth, asm etc which were clear logical languages. Then he drops what my young self called "phiilosophical bullshit into the thing i loved. I eventually had to read a book on general OOP to get it. (I got mediocre..not good). Now im older and get why its incredibly useful in large and team encironments. Still be superhappy to point out its flaws. C++ is the one language you just might accidentally create General ai in by programming while stoned. And not have anyone including yourself able to understand what you did later. "Wait is that recursive inheritance between three classes?"
People do understand quantum mechanics. When Feynman said it he meant that QM is not intuitive to us. But guess what? There are a lot of things in classical physics that are not intuitive, e.g. diffraction.
Yeah. Isnt it useless? Makes classes tightly coupled, breaks encapsulation, maybe something else. For me,that's enough. Composition can give all benefits of the inheritance without introducing the downsides.
I figure inheritance is used only if theres no interfaces in the language but I doubt such languages exist at all.
Really, does anybody agree with me? I have never needed inheritance yet and have also refactored systems from inheritance to composition and the intent of code became so much clearer.
If anything, Im really interested in seeing where inheritance can be used and what profits does it have, because now I dont see any use for it at all.
218
u/[deleted] May 16 '21
has anyone?