This is actually a very good comparison between real composition (referencing other objects) and…
Thai Pangsakulyanont
2
So, what would be a good terminology to differentiate between these two ways of doing inheritance?
I have stumbled upon this really interesting debate.
Regarding your question I think that Jeff M didn’t entirely get the point.
In my opinion the examples that you shown could refer to the Interface Segregation Principle (ISP) from SOLID principles.
- ‘designing types after what they are’:
Here designed classes are not following ISP and client is cluttered with interfaces it don’t need (e.g. poop) which results with mentioned earlier Gorilla-Banana problem as a side-effect:
class MurderRobotDog(MurderRobot, Dog):
pass
2. ‘designing types after what they do’:
Here (Barker, Driver, Killer) are applied correct interface segregation, client gets exactly what he require.
class MurderRobotDog(Barker, Driver, Killer):
pass