logoalt Hacker News

goatloverlast Wednesday at 8:03 AM3 repliesview on HN

Can't help but wonder if that isn't more the fault of Java's OOP design. Favoring composition over inheritance doesn't seem like something Smalltalkers and Rubyists had to worry as much about.


Replies

ch_123last Wednesday at 9:40 AM

The GoF book predates Java, and many of the examples in the book are in Smalltalk - so I think it's quite likely that composition over inheritance came from the Smalltalk community.

Problems with inheritance, such as the fragile base case problem, are intrinsic to inheritance, and not any specific language's implementation of it.

hoshlast Wednesday at 9:59 AM

Ruby does have language features for composition, and “composition over inheritance” has popped up in the community. I have also looked into the use of traits in Smalltalk.

show 1 reply
misja111last Wednesday at 8:26 AM

It was definitely also a fault of initial OOP in Java. Java's interfaces became a bit more flexible later on.

show 1 reply