[Dbix-class] Selecting Mixins with MI
Matthew Simon Cavalletto
simonm at cavalletto.org
Sun Jul 31 02:14:54 CEST 2005
Hello, and *delurk*.
I'm yet another CPAN author working in this space, and figured I'd
subscribe to see what you folks were up to and whether there was
anything I could learn for use in my DBIx::SQLEngine distribution.
I wasn't subscribed to the Class-DBI mailing list but read through
most of the recent discussion after the list closed, and wanted to
follow up on the "delegation vs. hooks vs. plugins vs. mixins"
thread. Each of those concepts can be implemented in different ways,
producing a certain amount of ambiguity, but I found the technical
portions of the discussion quite interesting.
I have also used the "dynamic MI mixins" approach and am quite fond
of it for allowing users to select various optional features,
including their own plugins.
I wrote Class::MixinFactory after I found myself implementing this
for yet another base class. There's not much too it: it creates new
packages that inherit from the base class and a flexible number of
mixin classes. It also uses its own re-dispatch method "$self->NEXT
($methodname, @_)" instead of NEXT's AUTOLOADer.
An example use is in DBIx::SQLEngine::Record::Class, which sets up an
ORM link between a caller's class and some data source, generally a
table with a primary key. Different classes may or may not need
caching, accessor generation, etc, so those are set up as optional
I'll be taking a closer look at your code in the days ahead...
More information about the Dbix-class