It might be nice to use in some very specific cases (e.g. addition-operation is a binary-operation AST node which is an AST node).
In most of the cases it just creates noise though, and you can usually do something different anyway to implement the same feature. For example in rust, just use enums and list all the possible cases and it’s even nicer to use than inheritance.
Some legacy Python code that already used inheritance. I had to extend it, and it was pretty infeasible to refactor the whole thing to not use inheritance. Not sure if I technically regretted that decision, but it was definitely painful, since Python inheritance makes it really hard to follow program control flow.
It was actually typed. Python had type annotations at the time.
I only wrote C++ very early in my career so I don’t remember much, but I’m sure I at least tried some inheritance in toy games I would write. All of that code was trash though by my standards today.
In over ten years of professional programming, I have never used inheritance without regretting it.
This applies to firewall rules too
When it’s the right tool, it’s incredibly useful. When it’s the wrong tool, and it often is, it racks up tech debt at an incredible rate.
It works great for technical constructs. E.g. A Button is a UI element. But for anything business logic related, yeah it’ll suck.
Even then there’s rarely a good reason to use inheritance instead of composition.
And not once have I regretted removing inheritance.
Do you include “traits” and “interfaces” under the title “inheritance”?
No because those are different things.
Just don’t use inheritance where more than a few descendants are predicted
It might be nice to use in some very specific cases (e.g. addition-operation is a binary-operation AST node which is an AST node).
In most of the cases it just creates noise though, and you can usually do something different anyway to implement the same feature. For example in rust, just use enums and list all the possible cases and it’s even nicer to use than inheritance.
That’s wild. What did you use it for?
Some legacy Python code that already used inheritance. I had to extend it, and it was pretty infeasible to refactor the whole thing to not use inheritance. Not sure if I technically regretted that decision, but it was definitely painful, since Python inheritance makes it really hard to follow program control flow.
Non typed inheritance, what could go wrong eh. You can just ‘add’ a function to a class dynamically in python, that is so bad.
Done any C++ classes & inheritance?
It was actually typed. Python had type annotations at the time.
I only wrote C++ very early in my career so I don’t remember much, but I’m sure I at least tried some inheritance in toy games I would write. All of that code was trash though by my standards today.