[Melbourne-pm] Invalid use of Exporter as a parent of a class

Bradley Dean bjdean at bjdean.id.au
Tue Nov 27 22:47:54 PST 2012


Greetings folks,

I've found myself having a conversation about why Exporter shouldn't be
included in the base of a class-defining perl module. This is my position,
such that this would be very bad code:
 
  # Bad code, don't inherit from Exporter in a class
  package My::Class;
  use base qw(Foo Bar Exporter);
  ...

I can't think of any good reason to do this - but my partner-in-discussion
has invoked "Damian Conway's methods" (Hi Damian, sorry to cause teeth
grinding if this does so) so I thought I'd see if I was missing something.

To my mind the only reason that someone would be tempted to inherit from
Exporter in a class was if you also wanted to export functions - and even
then the problems of then creating invalid inherited 'methods' from
Exporter would make this a horrible solution.

So then, thoughts?

Cheerio,

 Brad

-- 
Bradley Dean
Email: bjdean at bjdean.id.au Skype: skype at bjdean.id.au
Mobile(Aus): +61-413014395 WWW: http://bjdean.id.au/


More information about the Melbourne-pm mailing list