Friday 15 November 2013

"Classes. He would like to replace classes with delegation."

I had the intuition from my software engineering days, but for the last few months (due to our Forsaking Inheritance paper) I have been seeing stuff about dropping inheritance or advocating that inheritance is bad... everywhere.... from very old sources to very recent ones, spanning a period of nearly three decades...
  1. James Gosling 's interview that I first saw some months ago at Simon Peyton Jones' talk at the OPLSS'13 (There were two main questions: What would you take out? What would you put in? To the first, James evoked laughter with the single word: Classes. He would like to replace classes with delegation since doing delegation right would make inheritance go away. But it's like Whack-A-Mole (more laughter) since when you hit one mole, er, problem, another pops up.)
  2. Why extends is evil.
  3. Recent example from the C++ themed online conference GoingNative 2013, Inheritance Is The Base Class of Evil (general example of a talk, demonstrating that inheritance is still discussed as a "it would be best to avoid" feature.)
  4. Patterns for subclassing to avoid embarrassing situations with library clients, The Art of Subclassing.
  5. The are even refactoring options for it (e.g., IntelliJ's "Replace Inheritance with Delegation".)
  6. There are solutions with Java annotations like lombok's @Delegate
  7. delegate(*methods) in Ruby on Rails
  8. Go (the programming language) diverges from the usual notion of subclassing, by embedding types together (without late binding as mentioned explicitly) simplifying composition [SO]. The Gang of 4's crucial principle is "prefer composition to inheritance"; Go makes you follow it. (I liked how the so poster put it).
  9. The End Of Object Inheritance & The Beginning Of Anti-Rumsfeldian Modularity by Augie Fackler and Nathaniel Manista
  10. .... and last but not least a whole category of academic work on Subtyping, Subclassing, and the Trouble with OOP in general (article and refs by Oleg Kiselyov.)

No comments:

Post a Comment