The following table shows varying abstract base classes that are used all over python. However, I am a bit confused exactly (in this context)
what is the difference between the Abstract Methods
column and the Mixin Methods
column. Is one optionally implemented and the other not?
I've been mulling it over and every one of my "theories" doesn't seem to be right.
reference
mR_fr0g, yes, BufferedRequestHandlerMixin is implemented as an abstract class. It's common to implement mixins using abstract classes in Java, as the abstract keyword notes that the class is designed for reuse and isn't mean to be used by itself (it also obviously prevents you from using it by itself).
A mixin is a class that provides methods to other classes, but it's not considered a base class itself. 00:18 This special class is going to expose some methods that the derived class can utilize—methods that will essentially be mixed in to the derived class.
Mixins are sometimes described as being "included" rather than "inherited". In short, the key difference from an inheritance is that mix-ins does NOT need to have a "is-a" relationship like in inheritance. From the implementation point of view, you can think it as an interface with implementations.
A mixin is a class (interface, in WebAPI spec terms) in which some or all of its methods and/or properties are unimplemented, requiring that another class or interface provide the missing implementations.
Anything in the Abstract Methods column, you have to implement yourself. The ABC provides default implementations of the methods in the Mixin Methods column, implemented in terms of the methods you have to write.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With