3 ms·
Inheritance is flawed, in Java, mainly because it is the only organizing principle offered, so gets shoehorned into all kinds of problems where it is a poor fit
by ncmncm 5y ago
Inheritance is flawed, in Java, mainly because it is the only organizing principle offered, so gets shoehorned into all kinds of problems where it is a poor fit.
Inheritance is just the right thing once in a while, but Java coders are obliged to apply it well beyond its useful range.
- ivanche 5y agoWhat do you mean by "obliged to apply it"? For example, I very very rarely apply it and nobody is forcing me to create inheritance hierarchy.
- kaba0 5y agoJust because it exists doesn’t mean it has to be used beyond its intended domain. One is entirely free to create flat “hierarchies” in Java. But I agree that in hindsight, final classes as a default would be better. Fortunately nowadays, records and sealed classes remedy this for the most part in java.