Mike's Notes
Pipi needs multi-inheritance, so how?
Modelling nature and complex systems requires multiple inheritance, but CFML does not support it. Here are some initial notes on figuring out what to do. I discovered some possible solutions on Ben Nadel's blog.
Thank you, Ben Nadel.
Resources
- https://en.wikipedia.org/wiki/Mixin
- https://www.bennadel.com/blog/920-strange-coldfusion-component-shell-behavior.htm
- https://www.bennadel.com/blog/1551-exploring-mixins-and-coldfusion-components.htm
- https://www.bennadel.com/blog/2014-extending-the-application-cfc-coldfusion-framework-component-with-cfinclude.htm
- https://www.bennadel.com/blog/2482-creating-ruby-inspired-modules-in-coldfusion.htm
- https://www.bennadel.com/blog/2889-unexpected-scope-precedence-when-cfincluding-template-into-a-coldfusion-component.htm
- https://github.com/bennadel
- https://en.wikipedia.org/wiki/BORO
- https://westminster.academia.edu/ChrisPartridge
References
- Reference
Repository
- Home > Ajabbi Research > Library >
- Home > Handbook >
Last Updated
15/10/2025
Mixins and CFML
Mike is the inventor and architect of Pipi and the founder of Ajabbi.
When building Pipi 4, 20 years ago, I once wrote to software architect Sean Corfield asking how to implement multiple inheritance in CFML.
He replied, "Multiple inheritance is bad".
I'm using a database-driven workaround based on BORO at the moment, which works. The thing is, I need a better way to implement multiple inheritance in code.
This morning, for no real reason, I did a Google search for
"cfapplication multiple inheritance cfml"
And discovered what Ben Nadel came up with. He uses CFInclude to create a mixin.
From Wikipedia
"In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin's methods depends on the language. Mixins are sometimes described as being "included" rather than "inherited".
Mixins encourage code reuse and can be used to avoid the inheritance ambiguity that multiple inheritance can cause (the "diamond problem"), or to work around lack of support for multiple inheritance in a language. A mixin can also be viewed as an interface with implemented methods. This pattern is an example of enforcing the dependency inversion principle."
From Ben Nadel on 2013-06-07
" A couple of months ago, I read Practical Object-Oriented Design in Ruby: An Agile Primer, by Sandi Metz. I haven't reviewed the book yet, but I wanted to explore one of the concepts Metz talked about: Ruby Modules. From what I understood (and this may be somewhat off-base, I'm not a Ruby programmer), a module is a way to "inherit" behavior without using classical inheritance. Essentially, behavior is "included" into a class, rather than "inherited" into a class. In a language that only allows for single-class inheritance, a Module provides a mechanism for including behavior from several different sources. Furthermore, it allows the developer to borrow behaviors without worrying about the "is-a-type-of" inheritance relationship. It seems fairly interesting, so I wanted to see how this kind of behavior could be used in ColdFusion."
Code Sample
From https://www.bennadel.com/blog/1551-exploring-mixins-and-coldfusion-components.htm
Ben's blog posts go into much more detail. I will need to experiment and test. Maybe a combination of the existing Boro datamodel and this code might work. It adds a lot of complexity and could be a maintenance nightmare, but with Pipi managing it, it should be OK. Pipi runs on complexity.
Summary
The CFinclude can go in the CFcomponent and/or the CFfunction.
No comments:
Post a Comment