CPAN/@ISA and inheriting modules and namespace

jonasbn on 2003-08-15T07:24:24

At YAPC::Europe I heard a presentation by Mark-Jason Dominus (mjd/MJD). He stated that he would like to see more modules on CPAN that inherited from other modules on CPAN.

Since I am that kind of module builder and it gives me great opportunity to create some of the modules which I find useful. Well I am thinking whether this would require a module (package/class) namespace rule so you could easily see that a given module was a child class of another.

There are currently many "wrapper" modules on CPAN and many of them are modules inheriting from other modules. Some of these follow the naming convention *::Simple and the *::Lite namespace seem also to be growing.

So maybe what I am asking has already been decided, so the ::Lite and *::Simple surnames indicate that we are inheriting some given module.

But what happens when we start inheriting from these modules, will we end up with: *::Simple::Lite and *::Simple::Simple?

Well also this problem seem to have taken care of itself, apparently *::Simple::* and *::Lite::* seem to be quite controlled namespaces. I only found one weird one: Bot::BasicBot::Pluggable::Module::SimpleBlog::Store::SQLite, this one has the words Basic, Simple and Lite in its name - it must be easy to use?

At the same time you have the inheriting modules which do not use the naming conventions of *::Simple and *::Lite?

I guess that the way it works for now is ok, CPAN works and it grows...

The last problem is the modules which are not inheritable - now THEY are annoying ;)

Well I better stop these ramblings and go back to work...


Lite and Simple

koschei on 2003-08-15T07:38:51

I think I'd only want the Lite/Simple ones to be modules that provide simplified interfaces. There are other uses for subclasses (e.g. Email::Thread [which, in an ironic twist, doesn't subclass a ::Simple, but subclasses another module to let that other module use Email::Simple).

WWW::Mechanize is another great example of subclass, though I do, at times, wonder if it should in fact be delegating.

Inheritance

malte on 2003-08-15T17:58:58

I just wanted to add, that we shouldn't discriminate against different ways of code reuse. Perl's TMTOWTDI way of handling objects often makes delegation a much better way to "inherit" functionality, because you don't need to know about the innards of your super class (and you don't care if they change.)