Comment by pjc50

4 days ago

Delegation is a very useful part of composition. Almost all OOP languages have two techniques to delegate some methods to another object:

- manually write a bunch of forwarding methods and remember to keep them updated, or

- inheritance.

To be fair, the compiler generally forces you to keep the forwarding methods updated. It can be irritating, but there's little risk of forgetting in a statically-typed language.

Manual forwarding also operates as a forcing function to write small interfaces and to keep different pieces of logic separated in different layers, both of which feel like good design to me. (Though I'm not saying I'd turn my nose up at a terser notation for method forwarding, haha.)

...yes? Hence me saying that 'composition' and 'polymorphism' have often been unnecessarily coupled together in 'inheritance'?

Compare: Ruby mixins or Go embedded struct fields.