On Saturday, 1 March 2014 at 13:54:49 UTC, Araq wrote:
Araq: could you list the problems you see in the OO world?

I could list the problems, but that would fill books. So, I'll focus on a single aspect instead here: "Favour composition over inheritance". This is commonly regarded as the better solution (and I agree with it btw). Ok, fine, so we favour composition and don't use inheritance. If we don't use inheritance we have no subtyping either

Favouring composition over inheritance means not to create too deep class hierarchies. It doesn't mean not to make use of inheritance anymore at all. The deeper a class hierarchy the more inflexible: if you change the parent class of a class in a big hierarchy tree you break a lot of things (all subclass of the classs with the changed parent class are affected). So create light hierarchies and then go with composition. Overriding inherited methods is still a great way to achieve flexibility without breaking encapsulation.

Reply via email to