[go: nahoru, domu]

Jump to content

Mixin: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
In [[computer science]], a '''mixin''' is a group of [[function (programming)|function]]s which can be mixed into a class and become [[method (computer science)|method]]s. They allow certain classes to take on certain functionality in an [[object-oriented programming]] language (including languages that do not support [[multiple inheritance]]), just as if the class were a cooking dish and a mixin was a specific ingredient.
In [[computer science]], a '''mixin''' is a group of [[function (programming)|function]]s which can be mixed into a class and become [[method (computer science)|method]]s. They allow certain classes to take on certain functionality in an [[object-oriented programming]] language (including languages that do not support [[multiple inheritance]]), just as if the class were a cooking dish and a mixin was a specific ingredient.


Some of the functionality of mixins is provided by interfaces ([[interface (computer science)]]) in popular languages like Java and C#, but since an interface only specifies what the class must support and cannot provide an implementation, they are not as useful when refactoring out common behavior.
Mixins are also supported in a new model of [[Java programming language|Java]] [[class-to-class function]]s where a [[class (computer science)|class]] does not directly define its parent class, but rather the interface this class must provide. This allows for the same class to be instantiated with different parent classes. This concept originated in [[Lisp programming language|Lisp]].


== External links ==
== External links ==

Revision as of 23:47, 1 April 2005

In computer science, a mixin is a group of functions which can be mixed into a class and become methods. They allow certain classes to take on certain functionality in an object-oriented programming language (including languages that do not support multiple inheritance), just as if the class were a cooking dish and a mixin was a specific ingredient.

Some of the functionality of mixins is provided by interfaces (interface (computer science)) in popular languages like Java and C#, but since an interface only specifies what the class must support and cannot provide an implementation, they are not as useful when refactoring out common behavior.