Safe Navigation Operator “?.” for D2 ?

Bienlein jeti789 at web.de
Mon Mar 3 13:37:03 PST 2014


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.


More information about the Digitalmars-d mailing list