logoalt Hacker News

crabmusket11/20/20244 repliesview on HN

Mainstream OOP languages (looking at you Java) have failed to make composition as convenient as inheritance.


Replies

flakes11/20/2024

The common toolkits today (spring boot, google guice, etc) are much more focused on composition over inheritance, by injecting arguments and implementing pure interfaces rather than extending base classes. Older legacy Java frameworks and bad teachers are more at fault than the Java language itself IMO.

show 1 reply
_old_dude_11/20/2024

Very true, in Java, at least in the last 20 years, inheritance is de-facto deprecated, all new bits and bolts like enums, annotations, lambdas or records do not support inheritance.

So you have to use composition.

yxhuvud11/20/2024

How is composition inconvenient?

show 1 reply
watwut11/20/2024

How is composition in Java inconvenient?