The truth is you simply don't use inheritance much outside of theory. Only use it for a strict is-a relationship where you actually need to substitute it. And even then interfaces might fit your need better. Outside of that, composition feels like the way to go.
Even if it might be a good goal, unless you plan on avoiding all the APIs that force their object models on to you, you're still going to use a lot of inheritance.
I think I've encountered maybe one or two libraries ever that forced you to inherit from their base classes. Java ecosystem mostly embraces POJOs. Most of the times I use inheritance in relation to libraries is to make custom hacky overrides for certain behaviour. Anything explicitly exposed is usually clean.
This is pretty wrong. Inheritance and polymorphism is a key feature in a lot of APIs (this meme mentions Minecraft so just look at how you'd make a Fabric mod, you gotta use inheritance and interfaces even for basic stuff).
I think they’re referring to using interfaces instead of superclasses, which is kind of doable. I don’t remember the last time I actually used the “extends” instead of “implements” keyword. Haven’t modded any minecraft though
Yeah, for me it depends on what I’m doing. Example: I extend Spring Configuration beans all the time to add additional configuration on top of or in place of the parent class.
In my first 2 years in compsci all we used was C. Sometimes I'll catch myself writing a ton of code without objects out of habit and then realizing I could have saved myself hours.
I don't know what it is about Java, but having learned other languages prior to looking at Java source code, most of which incorporate aspects of OOP in their paradigm, Java to me just looks like wrong C++. It's unexplainable to me, but there is just something about the language that makes it seem convoluted and unappealing.
Its not that it's hard, its that its complicated. Lots of steps, which you often have to look up individually i assume. I tell myself a good month of putting time into learning something properly and you're golden, just need motivation and some tutorials
573
u/Srazkat Apr 06 '22
honestly what is hard about java ?