re-mix: mixins for C# and Visual Basic

Mixins are small bits of functionality that are useful to a wide variety of otherwise unrelated classes. In languages that support multiple inheritance mixins are added as secondary base classes while dynamically typed languages simply merge in the extra functionality. Since C# and VB don’t normally support these options, mixins are normally added using base classes that can become bloated or by a lot of copy-and-paste. Composition isn’t much help here, as the mixed-in methods and properties would need to be delegated to the internal object.

The re-mix project offers an alternative. Using runtime code generation, simple classes are combined with one or more mixin classes. While it has the appearance of multiple inheritance it doesn’t actually use it. Instead it uses a combination of object composition and a matching interface.

Continue reading on InfoQ