Mixin
Object-oriented Programming (OOP)
Overview
In object-oriented programming, a Mixin is a class that contains methods for use by other classes without having to be the parent class of those other classes.
Having said that, mixin is one of the styles of software development in which units of functionality are created in a class and then mixed in with other classes.
Typically, a mixin class acts as the parent class and will export the desired functionality to a child class without creating a rigid relationship.
Mixins are sometimes described as being “included” rather than “inherited”.
A mixin can also be viewed as an interface with implemented methods.
What Mixin tries to solve?
- Encourages code reuse.
- Avoids the inheritance ambiguity that multiple inheritance can cause (diamond problem)
- Used to workaround lack of support for multiple inheritance in a language.
Mixin vs. Inheritance
Yet to be documented here…