4 ms·
Inheritance is often used as an enabler for polymorphism in languages that don't support it in any other way. Somehow, it leaked out and convinced everyone tha
by bheadmaster 9mo ago
Inheritance is often used as an enabler for polymorphism in languages that don't support it in any other way.
Somehow, it leaked out and convinced everyone that it is a good thing on its own.
- goatlover 9mo agoAlso encapsulation and code reuse. Message passing if you go by the guy who coined the term.
- bheadmaster 9mo agoEncapsulation is possible without inheritance. And "code reuse" is a vague concept that had nothing to do with inheritance in particular. Not even gonna comment on "message passing".
- rhdunn 9mo agoThere are two types of inheritance: - interface/API based -- this is supported in modern languages via interfaces, traits, etc. - implementation/code based -- modern languages tend to only support single inheritance; they tend to also support default method implementations on the interfaces/traits
- goatlover 9mo agoIt's interesting that Python does support multiple inheritance.
- bheadmaster 9mo ago> interfaces, traits, etc. Those are actually mechanisms for achieving polymorphism. Inheritence inherently (heh) consists of "inheriting" parent class' internals and having ability to extend them. It is basically composition, polymorphism and monkeypatching in a trench coat.