[go: nahoru, domu]

Jump to content

Mixin

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 144.35.254.5 (talk) at 23:51, 1 April 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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 only useful for providing Polymorphism (computer science) and not for refactoring common behavior into a single place.