Found on slashdot: From Steeltoe: > For me, mixins work the way multiple inheritance and OOP should have > worked from the beginning. I no longer have to remember and overload > functions for all my base classes to work. I cleanly separate different > sets of functions in different modules, and no longer worry about > different states in different parts of my class-hierarchy. There are no > artificial boundaries between variables in my object(s). IMHO, objects > were never meant to be separated vertically and statically into multiple > classes, but horizontally and dynamically into multiple modules > collaborating at the task. (Just remember to call _functions instead of > using variables belonging to other modules). > > In Ruby, the best you can do is always begin by creating a module you can > mixin into later classes. Too bad this is not a common practice yet. Do > you know what I do? If I have modules that usually, but doesn't have to > "inherit" (include) from eachother, I instead include them all in my class > that I'm defining. I make no code in my classes (except for my libraries, > but I really shouldn't there either). Thanks to the order methods are > called, super and all other methods are called in the correct order as > long as I include them in the correct order (the order I want to for that > particular class for instance). Thus, I have no static inheritance > hierarchy that I depend on, and further split up my modules. I can > statically :( remove and dynamically add modules as I please in my > classes. Very simply put: Elegant. Just remember that including modules is > semi-horizontal as opposed to inheritance, so widely different modules > shouldn't contain the same variable names and methods (but you can alias > them if they start conflicting). And yes, I do use single inheritance and > include in modules were appropriate. This technique works with deep > classes and modules intuitively. Any comments on this style of programming? It sounds like an interesting new approach I haven't seen before. -- spwhite / chariot.net.au