6 ms·
Do they? I rarely see people using it directly and I think this is fine
by high_na_euv 3y ago
Do they? I rarely see people using it directly and I think this is fine
- angiosperm 3y agoMost of us have no contact with Java. But Java offers little else than inheritance to use to organize a system, so Java coders use it for everything. They are not exactly wrong, except in using Java at all. But sometimes is all that is allowed.
- pgwhalen 3y agoThis is much less true for modern Java than it used to be, with records, pattern matching, sealed classes, etc. The trick though is you actually have to use modern Java, which means you need to both be on the right version of Java, and have developers that understand the value/power of these newer constructs. Which is surprisingly rare for a programmer that self-identifiers as a Java programmer.
- bedobi 3y agojava offers composition, like pretty much all programming languages if you have a person class and you have students and teachers the correct thing to to is NOT to make student and teacher inherit from person it's to make student and teacher have a person attribute + the other attributes that constitute a student and teacher respectively
- kuang_eleven 3y ago"correct" is certainly not the right way to put that. Inheritance and composition here are both fully valid methods for modeling the relationship, and the decision to use either should be dependent on how the models are being used and the expectation for future extension.
- angiosperm 3y agoBy "correct" here you only mean fashionable. Either approach works. Each has its merits and its costs. Any big enough system will have parts that are most sensibly built object-oriented, and other parts that are more reasonably functional, plus anything else you can think of.
- brodo 3y agoSame here. For me, implementation inheritance is a code smell. But I rarely see it.