Module includes and "composition over inheritance"


#1

I’ve got a bit of philosophical question. In the Hanami guides it is stated that Hanami prefers composition over inheritance to avoid framework superclass antipattern and the example is how it provides modules to include instead of base classes to inherit from.

“Composition over inheritance" means that classes should achieve polymorphism by containing instances of other classes rather than inheriting from them (i.e. be composed of them) which is not the case here. In fact, module inclusion is achieved by Ruby VM through inheritance so including a module or inheriting from a base class is in this case little more than style preference since they are technically almost the same. Mixins are essentially, under the hood, a sane alternative to multiple inheritance that avoids the “diamond problem”.

Which leaves me wondering why Hanami emphasises including modules everywhere instead of having a base class?