5 ms·
I see the author fighting really hard against a paradigm that was already well known to be suboptimal 20 years ago .. "Favor composition over inheritance" is a
by misja111 9mo ago
I see the author fighting really hard against a paradigm that was already well known to be suboptimal 20 years ago ..
"Favor composition over inheritance" is a phrase that became common knowledge in e.g. the Java world half way during the 2000's.
It was even already mentioned in the famous Design Patterns book from the GOF in 1994.
- goatlover 9mo agoCan'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.
- misja111 9mo agoIt was definitely also a fault of initial OOP in Java. Java's interfaces became a bit more flexible later on.
- wk_end 9mo agoWhat's this referring to?
- ch_123 9mo agoThe 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.
- hosh 9mo agoRuby 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.
- lloeki 9mo agoAbsolutely, usage of inheritance is (comparatively to Java/C++/Python) quite rare in Ruby. People favour modules to compose (e.g Enumerable), and more generally interfaces (e.g duck-typed StringIO vs IO/File/etc...) If you throw in RBS and start to type Ruby things then you start to see that Go-style interfaces pop up quite frequently.