Badger::Base
- Class::Base++
- Common functionality
- Blunt instrument
- Clean, lean and mean
Thus Spake Andy:
Badger::Base
is a new and improved version of Class::Base
which was
previously hewn from the living rock of TT. A base class is where you put
all your shared functionality that you want all (or most of) your other
objects to inherit. The problem is that a base class (and OO inheritance
in general) is a blunt instrument. Every time you add something to your
base class you're effectively adding it to all modules that inherit from
it. This can cause problems if those modules weren't expecting to have a
new method suddenly appear from under their feet. This is also one of the
reasons why I never made any major changes to Class::Base
- because adding
a single new method would have affected every module ever written that uses
it as a base class. The Badger approach is to keep it clean, lean and mean
(very much like Class::Base) and to provide other mechanisms to help
with class construction. In summary, OO is broken, but it's the best thing
we've got right now.
By the way, Badger::Base
works as a base class for all object types, not
just those built from hash refs. The new()
method creates a hash ref by
default, but you can implement your own constructor to create objects built on
any other kind of reference. All the other Badger::Base
methods Just
Work™ regardless of underlying type.