Well, I just got done reading this post about multiple inheritance in as3 which probably should have been titled AS3 mixin technique, because that is more or less what it is, check out the wikipedia article on mixins for some history and pros and cons.
I’ll will admit straight out that I am a supporter of MI and Mixins and the like. I am not much for the aristotelian idea of the universe, sometimes A is A, and sometimes it’s both A and B and MI, when used responsibly helps you to find more elegant and concise solutions to a great many problems. Just because people use something incorrectly in some instances doesn’t make that thing inherently evil, take for instance perscription drugs, would you rather painkillers where completely banned or never prescribed just because some or even alot of people abuse them? No, a great many things when used excessively with little understanding of what it is and how it works can be called evil, but they aren’t, the people who abuse them are evil, let’s start calling a spade a spade. The problem with MI and Mixins is not that they are evil, it’s that evil people use them for nefarious purposes.
Anyway, back onto topic, I liked the guys article, and to be honest, he was pretty brave for putting it up, the minute you say something about MI, either way, a “discussion” read “flamegeddon” ensues, not always, but it’s generally a risk when you start throwing words like Inheritance around with words like Multiple.
I got to thinking about about the framework I’ve been writing, which has a Plugin Architecture that for all intents and purposes could be adapted to a multiple inheritance scheme, or to be more precise a Mixin, why a Mixin you ask? Well, because what we are creating isn’t meant to be instantiated, not in the real sense anyway, it’s a thing that adds it’s functionality to an instantiated object.
In the example given in the article, this was done via implementing an interface and then including an as3 file with just method declarations, clever, but as has been pointed out, it’s kind of dirty in the sense of most programmers would be offended by the unstructured clutter of a bunch of free floating as3.
So, here is the mixin code: