Alex Mueller on Software and Technology 
Sunday, December 02, 2007

Do you ever learn a new trick, perhaps a new pattern or practice, and then discover yourself looking for reasons to apply it? Wouldn't it be great to be able to create an interface that contains an implementation, and then implement one or more interfaces like it to inherit desired functionality? Multiple inheritance does not exist in C# nor Java, but there are ways to simulate MI. One such was is to create "mixins."

Conceptually, a mixin is an interface that contains implementation details. In some situations we have a need to inherit additional functionality, but we do not want the overhead of extending a class. Essentially, we "mix" functionality at run time to achieve MI. In C#/Java, we can implement zero to many interfaces, hence the reason why mixins are thought of as interfaces. While we cannot actually provide implementation details within an interface and we cannot extend more than one class, we look for tools to help us achieve this functionality.

In any given project I typically reference functionality provided by the Castle project. Aspect# is a Castle project that provides aspect oriented programming for C#, and the functionality of mixins. It provides a good example of what mixins are, but the project is relatively stale.

Another project that provides AOP and mixins is Spring.net. I have not used Spring.net before because I have always used Castle for my IoC and interceptor needs. I downloaded Spring.net and began exploring the AOP functionality and their flavor of mixins, which they refer to as "introductions." The demo applications are easy to run. Aspect# does appear to be less involved, but I can get used to Spring.net's introductions.

What I am looking for now is a good reason to use mixins. When holding a hammer, everything is a nail. Well, after learning a new trick, I want to use it. Even though MI is not necessary, nor is inheritance, what are some good reasons why multiple inheritance might be necessary? Besides logging and emailing, I am looking for a reason to inherit functionality at runtime, intercept some calls, and implement my mixin. If I can help me think of a good reason to have multiple inheritance, I will put together a sample application demonstrating mixins.

Sunday, December 02, 2007 10:37:39 PM (Mountain Standard Time, UTC-07:00) | Comments [0] | Design | Technology#
Comments are closed.
MuellerDesigns.net
Search
On This Page
The Split Personality of the Tester/Developer
Cross Site Scripting (XSS)
Creating files with FSUTIL
PowerShell Management Library for Hyper-V
Installing Windows 7
Installing Linux in Hyper-V
Internet Explorer 8 Release Candidate 1
PowerShell Documentation
Automate Daily Tasks with PowerShell
SketchPath XPath Editor
Software Testing - Revisited
Architecting Buildings and Software
NBCOlympics.com with Silverlight
Marker Interfaces and C# Attributes
Most Popular
JavaScript ReplaceAll Functionality
What is polymorphism?
What is composition?
Sorting with IComparable and IComparer
Applying the Observer Pattern in ASP.NET
MVP in ASP.NET
What is abstraction?
What is encapsulation?
What is a class?
What is inheritance?
Authentication in ASP.NET
Calendar Controls
XPathNavigator.CheckValidity new for 2.0
SQL Server 2005 Connection Issues
Auto-attach to process '[####] aspnet_wp.exe' on m...
What is an object?
FreeTextBox
VMWare and VPC
An Example of Reflection using C#
Changing File Ownership In Vista and Longhorn
Archive
Links
Categories
My Local Blog Map
Blogroll
About
Powered by:

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
MuellerDesigns.net

Sign In

Help Those In Need
The Hunger Site
Ronald McDonald House Charities (RMHC) of Western Washington & Alaska