06Sep2022
Design Pattern:
Mixin
is only used to add functionality to objects.- The inheritance is not implying an is-a relationship
A child class uses multiple inheritance to combine the mixin classes with a parent class. Since Python doesn’t define a formal way to define mixin classes, it’s a good practice to name mixin classes with the suffix Mixin.
An example of a mixin in the real world is visible on the Window interface in a browser environment. The Window object implements many of its properties from the WindowOrWorkerGlobalScope and WindowEventHandlers mixins, which allow us to have access to properties such as setTimeout and setInterval, indexedDB, and isSecureContext.