Abstract classes vs. interfaces vs. mixins

后端 未结 7 1546
难免孤独
难免孤独 2021-01-29 20:10

Could someone please explain to me the differences between abstract classes, interfaces, and mixins? I\'ve used each before in

7条回答
  •  忘掉有多难
    2021-01-29 20:34

    Basically an abstract class is an interface with some concrete implementation. An interface is just a contract that has no implementation detail.

    You would use and abstract class if you want to create common functionality amoung all of the objects that implement the abstract class. Keeping with the DRY (Don't Repeat Yourself) principle of OOP.

提交回复
热议问题