Why avoid subtyping?

前端 未结 8 936
长发绾君心
长发绾君心 2020-12-02 07:55

I have seen many people in the Scala community advise on avoiding subtyping \"like a plague\". What are the various reasons against the use of subtyping? What are the altern

8条回答
  •  一整个雨季
    2020-12-02 08:17

    I don't know Scala, but I think the mantra 'prefer composition over inheritance' applies for Scala exactly the way it does for every other OO programming language (and subtyping is often used with the same meaning as 'inheritance'). Here

    Prefer composition over inheritance?

    you will find some more information.

提交回复
热议问题