mixin

Is it possible to implement mixins in C#?

I've heard that it's possible with extension methods, but I can't quite figure it out myself. I'd like to see a specific example if possible. Thanks! ...

java traits or mixins pattern?

Is there a way to emulate mixins or traits in java? basically, I need a way to do multiple inheritance so I can add common business logic to several classes ...

What are some good examples of Mixins and or Traits?

I was reading up on Ruby, and learned about its mixins pattern, but couldn't think of many useful mixin functionality (because I'm not used to thinking that way most likely). So I was wondering what would be good examples of useful Mixin functionality? Thanks Edit: A bit of background. I'm Coming from C++, and other Object languages, b...

What do you call an object level equivalent of Mixin/Traits system, is there a Pattern name for it?

I previously asked about what Mixins were, and have begun to get the gist of what the pattern means. But it got me wondering if there is a common pattern name for doing something like Mixins at an Object level as opposed to the Class level. Pseudo code (in some non existent language): Class MyClass { function foo() { ...

Groovy Mixins?

I'm trying to mix-in a class in my Groovy/Grails app, and I'm using the syntax defined in the docs, but I keep getting an error. I have a domain class that looks like this: class Person { mixin(ImagesMixin) // ... } It compiles fine, but for some reason it won't work. The file containing ImagesMixin is located in my /src/groovy/...

dojo: inheritance with default value - the mixin doesn't happen...

I wish to declare a new dojo class inheriting from an existing dojo class, but with my own choice of default values for the class's properties. (The user can still override those values.) I am declaring my own version of the dijit.form.FilteringSelect such that: the hasDownArrow property defaults to false (rather than the standard tr...

What is a Mixin, and why are they useful?

In "Programming Python", Mark Lutz mentions "mixins". I'm from a C/C++/C# background, and I've not heard the term before. What is a mixin? Reading between the lines of this example (which I've linked to, 'cause it's quite long) I'm presuming it's a case of using multiple inheritance to extend a class as opposed to 'proper' subclassing....

Is mixin considered a design pattern?

Are mixins considered a design pattern? Structural? ...

Spring introductions with dynamic implementation

I am trying to use Spring framework to dynamically implement a specific interface (lets call it I) for a class (let call it C). In Spring this is called introduction (mixin in other languages). In compile time C doesn't implement I. Using the @DeclareParents annotation I can do it in AspectJ syntax. The problem is that the actual imple...

Implement Mixin In Java?

Using Java 6, how can I implement a mixin? It is very easy and possible in Ruby. How can I get similar in Java? ...

What is the difference between an Abstract Class and a Mixin?

I just found an article on a framework in Java that apparently allows it to support Mixins and something called Composite Oriented Programming (which for all I know might even be the same thing...) I've also heard of/worked with AOP, and I'm not sure how it differs from this either... ...

Windsor MixIn is a Singleton?

I have a MixIn that requires some state to operate. I am registering it as so.. container.Register(Component.For(Of ICat) _ .ImplementedBy(Of Cat) _ .LifeStyle.Transient _ .Proxy.MixIns(New MyMixin())) When I call container.Resolve(of ICat), I get back a prox...

LinFu - can't quite see how to do what I want

Just found LinFu - looks very impressive, but I can't quite see how to do what I want to do - which is multiple inheritance by mixin (composition/delegation as I'd say in my VB5/6 days - when I had a tool to generate the tedious repetitive delegation code - it was whilst looking for a C# equivalent that I found LinFu). FURTHER EDIT: TO...

Abstract class + mixin + multiple inheritance in python

So, I think the code probably explains what I'm trying to do better than I can in words, so here goes: import abc class foo(object): __metaclass__ = abc.ABCMeta @abc.abstractmethod def bar(self): pass class bar_for_foo_mixin(object): def bar(self): print "This should satisfy the abstract method require...

Rails: How to override stylesheet_path

Hi, I've been trying to override Rails' stylesheet_path helper, but I haven't found a way how. I can't just open the ActionView::Helpers::AssetTagHelper module and override it there, because Rails won't pick up my new method. I know it's probably because the module gets mixed in, so how do I get around that? ...

Synthesize a few classes using different combination of member functions

i am interested to synthesize a few classes which will have some/all of the functions as in the class res_obj. struct res_obj { int* res_; res_obj() ///method 1 : no arg constructor : res_(0) { } explicit res_obj(int value) ///method 2 : single arg constructor : res_(new int(value)) { } ...

Abstract classes vs. interfaces vs. mixins

Could someone please explain to me the differences between abstract classes, interfaces, and mixins? I've used each before in my code but I don't know the technical differences. (And yes, I've searched, but everything I found was either too technical or otherwise unhelpful.) ...

Mixins vs. Traits

What is the difference between Mixins and Traits? According to Wikipedia, Ruby Modules are sort of like traits. How so? ...

Would extracting page metadata be a good use of multiple inheritance?

I was wondering if I have a couple of models which both include fields like "meta_keywords" or "slug" which have to do with the web page the model instance will be displayed on, whether it would be advisable to break those page metadata elements out into their own class, say PageMeta, and have my other models subclass those via multiple ...

Mixing Multiple Traits in Scala

Quick Note: Examples from this tutorial. Suppose I have the following Traits: Student, Worker, Underpaid, Young How could I declare a class (not instance) CollegeStudent with all these traits? Note: I am aware of the simplests cases, such as CollegeStudent with one or two Traits: class CollegeStudent extends Student with Worker ...