plugins, hooks and subclassing

Tom Hukins tom at
Thu Oct 11 09:45:48 PDT 2007

On Fri, Oct 05, 2007 at 04:54:28PM +0100, Oliver Gorwits wrote:
> For a module which is OO with no functional interface, as the author
> I'd prefer not to have to touch lots of the code to add hooks. This
> is something OO naturally serves well, to my mind.

Yes, that sounds sensible to me.  I held off replying in case someone
had more helpful ideas, but as nobody's replied yet I thought I might
as well.

> What opinions on plugins/hooks/subclassing are out there?

Plenty, I'm sure. :)

Personally, I'd suggest your user tries to subclass your module:
  sub method {
      my $self = shift;
      # Do things here, if necessary
      # Do things here, if necessary

If Perl's inheritance order causes problems, take a look at Class:C3.
If you feel you need a heavyweight plugin system, use
Module::Pluggable.  I've used both, and like both, but wouldn't use
them unless I had a problem with what Perl already provides.


More information about the MiltonKeynes-pm mailing list