On 2015-08-31 14:20:23 +0000, Abdulhaq said:

Inheritance certainly is 'the base class of all evil'. I have a theory that the reason inheritance is so overused in OOP languages lies in the way it is taught - the OOP aspects cover much of the syntax of the language and hence much teaching material revolves around inheritance. This makes the student believe that inheritance is therefore the 'right way' to proceed.

I think what's missing is, that inheritance should be used with a type-system view in mind. It makes sense to model "typed things" but not to model functionallity / re-using of functionallity. This is much bettern done with a concept like mixins.

And mixing both is a very powerful way to model complex system. You "just" need to know when to use one or the other.

Many years of pain have, however, taught me to avoid inheritance and to prefer composition - even/especially when using e.g. Java.

Because all those OOP languages are to dogmatic about it's use. C++ is free, but is missing (not sure if still) the template and mixin power of D.

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

Reply via email to