Ayende @ Rahien

Refunds available at head office

What does Mixin mean?

Bill Wagner has a proposal about the usage of mixins. He is talking about having a marker interface with minimal methods (or no methods), and then extending that using extension methods. To a point, he is correct, this will give you some sense of what a mixin is. But it is not enough.  

It is not enough because of the following reasons:

  • It is not really a cohesive solution. There is no really good way to specify something like SnapshotMixin. You need interface and static class and inherit from the marker interface, etc. Those are... problematic. I want to just be able to say: "also give me the functionality of this class"
  • A more important issue is one of state. The examples in Bill's proposal are all stateless methods, but I want to have a stateful mixin. I can think of several hacks around that, but they are hacks, not a proper way to work.

Comments

Francois Tanguay
11/26/2007 09:13 PM by
Francois Tanguay

Cohesion isn't an all-or-nothing philosophy. It is something we should tend for when it applies.

I think Mixin (Tag) interfaces + Extension Methods greatly overcome any drawbacks due to less cohesion (Discoverability being one.)

State "infrastructure" required by stateful mixins should be provided by the Mixin Interface itself.

Comments have been closed on this topic.