Posted: Tue Jan 15, 2008 12:04 pm
It avoids MI where MI might otherwise cause problems. To put it another way, it makes fine-grained re-use through inheritance feasible, safe, and efficient. MI does not (which is one of the reasons why the FAQ advises against reuse-through-inheritance).Solar wrote:Erm... which achieves what, exactly?
It's not a total mess -- it's perfectly linear, and completely documented right at the point where Derived is declared.I mean, aside from making a total mess of what should be an inheritance graph,
Derived => BarBase< FooBase <UltimateBase> > => FooBase< UltimateBase > => UltimateBase
It's a more flexible form of inheritance... I wouldn't call it butt-ugly. It is the basis for policy-based class design and is similar to the Curiously Recurring Template Pattern.scaring the majority of C++ coders (who didn't really grasp templates even after all those years) witless, and turning it into something butt-ugly? (Not that the rest of C++ actually smells of roses. I) )
For example, you can use this technique to stitch together several "partial classes". Each mixin could implement one aspect of the overall class, like a set of related properties and their getters/setters. I've found this technique extremely useful for fine-grained code re-use in the past. Maintainers haven't had any trouble with it -- Like I said, once you understand how it works, it's completely self-documenting.
I disagree about "proper design". Some problems naturally lead to the multiple "is-a" relationship. Look at the example in the FAQ you linked to (e.g. -- GasPoweredLandVehicle). If you mean using an alternative like Bridge, that works if the conditions are right, but requires a lot of extra code and removes a certain amount of flexibility.Most of the problems involved in a "diamond pattern" can be solved by a) proper design, and / or b) public virtual inheritance.
Regarding virtual inheritance, I suppose it works, but IMO it is more conceptually complicated than template-based mixins. Just look at all the guidelines for proper use and the rules regarding constructor/destructor calling order in the FAQ you linked to... Yuck. The mixin way just uses single inheritance, which is very easy to understand.
An aside: Must your tone be so belligerent when you discuss language issues?