Badger::Exporter
- OO version of Exporter.pm
- Inheritance Just Works™
- Easy export hooks
- Tiered API
- Package variables
- Class methods
- Metaprogramming
Thus Spake Andy:
Badger::Exporter
is an OO version of the Exporter
module where inheritance
Just Works™. If you create a subclass of a module
then it will automatically export everything that its base class(es) export.
Right the way up the chain. It also makes it easy to define custom export
hooks - something that is a little tedious using Exporter
.
Badger::Exporter
started life as an OO wrapper around Exporter
. The code
evolved and ended up being twice as large and four times as complex as it
needed to be. So I eventually bit the bullet and re-implemented it using all
of the core core from Exporter
, but re-jiggled into my OO framework. It's now
much smaller, simpler and faster. Code re-use is good, but sometime coder
re-use is just as important. The kind souls who developed Exporter
wrote down
a clear and concise description of the correct algorithm to use. In fact, they
wrote it down in Perl code so it was really simple to adapt. Conclusion:
algorithms are more important than implementations.
Badger::Exporter
, like most of Badger, has a tiered API that allows you
to hook into different levels of complexity. At the lowest level, everything
is done using the lowest common denominator of package variables. Then we
provide some methods operating at a higher level of abstraction which
effectively set these variables for you. They might also perform other tasks,
like validation, etc., as a convenience and/or to hide implementation details.
Above that we have a metaprogramming layer for those who want it. This is
effectively a layer of short-cuts to having these class methods called for
you.