Abstract classes vs. interfaces vs. mixins

后端 未结 7 1407
难免孤独
难免孤独 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:36

    The meaning of 'Mixin' is excellently defined by Joshua Bloch in his effective Java book. An excerpt from the same book:

    "mixin is a type that a class can implement in addition to its “primary type” to declare that it provides some optional behavior. For example, Comparable is a mixin interface that allows a class to declare that its instances are ordered with respect to other mutually comparable objects. Such an interface is called a mixin because it allows the optional functionality to be “mixed in” to the type’s primary functionality."

    0 讨论(0)
提交回复
热议问题