Inheritance for me seems to work best when the inheritance relationship exists in the domain problem I'm modelling.
A triangle is a polygon, etc.
If my main goal is code re-use I always favor composition, and believe that abstractions should depend on details, not vice versa (as is the case with inheritance, details depending on abstractions)
Dependency inversion - YES! classes should be honest and declare in the constructor what they need to function correctly.
Dependency injection - If the app is large enough that it make sense to use a DI container, sure. Almost all of what I write these days is either Angular or ASP.NET Core web applications, so Dependency injection is pretty much a guarantee.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Inheritance for me seems to work best when the inheritance relationship exists in the domain problem I'm modelling.
A triangle is a polygon, etc.
If my main goal is code re-use I always favor composition, and believe that abstractions should depend on details, not vice versa (as is the case with inheritance, details depending on abstractions)
Do you use dependency inversion/injection in the composition case? Otherwise depending on the details seems rather unusual to me :)
Dependency inversion - YES! classes should be honest and declare in the constructor what they need to function correctly.
Dependency injection - If the app is large enough that it make sense to use a DI container, sure. Almost all of what I write these days is either Angular or ASP.NET Core web applications, so Dependency injection is pretty much a guarantee.