Hal Helms’ Mixup

  • Post author:
  • Post category:Uncategorized

I just read an article by Hal Helms in the February issue of ColdFusion Developer’s Journal. The article title is “Mixins” (excuse the pun in my post tile). I was curious what this unfamiliar term might mean. It turns out that a Mixin is similar to a technique in object oriented programming called Inheritance: “…derived classes, take over (or inherit) attributes and behaviour of…base classes. It is intended to help reuse of existing code with little or no modification.” (WikiPedia) However, Mixins are not Inheritance because a Mixin combines pieces of two separate classes to create a new class. In the article, Hal describes extending a Teacher class and a Student class to create a StudentTeacher class. The benefit is that you can reuse parts of the two parent classes, thus avoiding duplication.My first reaction to this article was, “Do we really have to make a new term to describe what we already know as Inheritance?” But upon further research, I discovered I was jumping to conclusions. The practice of using Mixins is trying to avoid problems with Multiple Inheritance. What if the two parent classes both define the same function, but a little differently? Which should be right? Mixins solve this and other problems by allowing you to pick and chose what you need from the two parent classes. And Hal admirably describes how to do this in ColdFusion. I’m not going to show any of that here though, go read the article! 😉