Mixin

mixinsinter-type declarationsmixed in
In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes.wikipedia
101 Related Articles

Multiple inheritance

diamond problemmulti-inheritanceDiamond inheritance problem
Mixins encourage code reuse and can be used to avoid the inheritance ambiguity that multiple inheritance can cause (the "diamond problem"), or to work around lack of support for multiple inheritance in a language.
Alternate methods of object composition not based on inheritance such as mixins and traits have also been proposed to address the ambiguity.

Object-oriented programming

object-orientedobject orientedobject-oriented programming language
In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes.
In some languages classes and objects can be composed using other concepts like traits and mixins.

Dart (programming language)

DartDart programming languageECMA-408
It supports interfaces, mixins, abstract classes, reified generics, static typing, and a sound type system.

Flavors (programming language)

FlavorsNew FlavorsMIT Flavors
Mixins first appeared in the Symbolics's object-oriented Flavors system (developed by Howard Cannon), which was an approach to object-orientation used in Lisp Machine Lisp.
Flavors, an early object-oriented extension to Lisp developed by Howard Cannon at the MIT Artificial Intelligence Laboratory for the Lisp machine and its programming language Lisp Machine Lisp, was the first programming language to include mixins.

D (programming language)

DD programming languageD language
C++ multiple inheritance is replaced by Java-style single inheritance with interfaces and mixins.

Trait (computer programming)

traitsTraitTraits class
It natively supports Trait and mixin based object composition via function objects that implement additional behavior and then are delegated via or to objects that are in need of such new functionality.
For inter-object communication, traits are somewhat between an object-oriented protocol (interface) and a mixin.

Common Lisp Object System

CLOSCLOS MOPCommon Lisp Object System (CLOS)
In New Flavors (a successor of Flavors) and CLOS, methods are organized in "generic functions".
Flavors introduced multiple inheritance and mixins, among other features.

Class (computer programming)

classclassesPartial class
In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes.
Some languages have special support for mixins, though in any language with multiple inheritance a mixin is simply a class that does not represent an is-a-type-of relationship.

JavaScript

Server-side JavaScriptclient-side JavaScriptJS
Even though the firstly described approach is mostly widespread the next one is closer to what JavaScript's language core fundamentally offers - Delegation.

Ruby (programming language)

RubyRuby programming languageRuby Application Archive
Already present at this stage of development were many of the features familiar in later releases of Ruby, including object-oriented design, classes with inheritance, mixins, iterators, closures, exception handling and garbage collection.

Inheritance (object-oriented programming)

inheritancesuperclasssubclass
A subclass can then inherit or simply reuse this functionality, but not as a means of specialization.

Racket (programming language)

RacketDrRacketPLT
These include a mixin class system, a component (or module) system as expressive as ML's opaque ascription, and pattern matching.

Tcl

Tcl/TkTool Command LanguageTcl programming language

XOTcl

XOTcl provides language support for design patterns via filters and decorator mixins.

Scala (programming language)

ScalaScala programming languageScala.js
Class abstractions are extended by subclassing and by a flexible mixin-based composition mechanism to avoid the problems of multiple inheritance.

Raku (programming language)

RakuPerl 6Niecza
Roles in Raku take on the function of interfaces in Java, mixins in Ruby, and traits in the Smalltalk variant Squeak.

Aspect-oriented programming

aspect-orientedAOPaspect oriented programming
Interfaces combined with aspect-oriented programming can also produce full-fledged mixins in languages that support such features, such as C# or Java.
Aspects relate closely to programming concepts like subjects, mixins, and delegation.

Decorator pattern

decorator
The decoration features (e.g., methods, properties, or other members) are usually defined by an interface, mixin (a.k.a. trait) or class inheritance which is shared by the decorators and the decorated object.

Abstract type

abstract classabstractabstract classes
Other names for language features that are (or may be) used to implement abstract types include traits, mixins, flavors, roles, or type classes.

Code reuse

software reusereusere-use
Mixins encourage code reuse and can be used to avoid the inheritance ambiguity that multiple inheritance can cause (the "diamond problem"), or to work around lack of support for multiple inheritance in a language.

Protocol (object-oriented programming)

interfaceinterfacesprotocols
A mixin can also be viewed as an interface with implemented methods.

Method (computer programming)

methodsmethodabstract method
A mixin can also be viewed as an interface with implemented methods.

Dependency inversion principle

dependency inversiondependencies
This pattern is an example of enforcing the dependency inversion principle.