• asyncrosaurus@programming.dev
    link
    fedilink
    English
    arrow-up
    12
    arrow-down
    1
    ·
    edit-2
    1 year ago

    6First off, Inheritance is not “dead”. We all just learned to favour interface inheritance over class inheritance.

    Secondly, class inheritance is not bad or useless, it’s just poorly taught and wildly overused. The fact that the article still uses the bullshit Animal kingdom example is indicative of that. There’s no value in trying to model cats and dogs in OOP.

    Inheritance is pretty useful in niche scenarios, mostly involving polymorphism and probably in the context of Library or Framework code. Trying to re-use code between classes with inheritance is always the incorrect approach. Two classes that are unrelated but have similar properties don’t actually need a common base class, they can each have their own version of the data.

    The big, big, big problem outside the education system comes back to the top down, design-first approach. There’s still this strange practice of trying to model class hierarchies and abstract classes in neat little diagrams before you’ve actually started writing code. No UML type document has ever survived contact with the real world. If you need any form of inheritance, it will become obvious as you build out your system.