Should inheritance (of non-interface types) be removed from programming languages?

前端 未结 20 2286
旧时难觅i
旧时难觅i 2020-12-30 05:20

This is quite a controversial topic, and before you say \"no\", is it really, really needed?

I have been programming for about 10 years, and I can\'t honestly sa

20条回答
  •  感情败类
    2020-12-30 05:47

    I believe a better mechanism for code re-use which is sometimes achieved through inheritance are traits. Check this link (pdf) for a great discussion on this, including the distinction between traits and mixins, and why traits are favored.

    There's some research that introduces traits into C# (pdf).

    Perl has traits through Moose::Roles. Scala traits are like mixins, as in Ruby.

提交回复
热议问题