Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: What is present best practices for lightweight plugins?

by Rhandom (Curate)
on Apr 03, 2012 at 13:59 UTC ( #963250=note: print w/replies, xml ) Need Help??

in reply to What is present best practices for lightweight plugins?

Be careful about using Module::Pluggable. Each time you run your script Module::Pluggable has to search through the entire INC path, and as part of that searching it will load every matching module. So, you get a win in that you can abstract out parts of your code or use separate distributions. But you also get a heavy penalty in that you might be loading large chunks of code unrelated to your current task at hand.

If you don't care to allow for arbitrary extension by third parties, then I'd use something like autouse or AutoRole to mix in known functionality.

If you want third party extensions but without the bloat, then a mapping of method name to module name is a way to go.

Alternately you could use a hybrid approach and scan @INC for module names - but don't load them unless a method that maps to a module is called.

However, with all that said, Module::Pluggable might be doing exactly what you want. I haven't had any of my personal projects ever fall into that category.
my @a=qw(random brilliant braindead); print $a[rand(@a)];
  • Comment on Re: What is present best practices for lightweight plugins?

Replies are listed 'Best First'.
Re^2: What is present best practices for lightweight plugins?
by BerntB (Deacon) on Apr 03, 2012 at 17:35 UTC

    Thanks, good advice.

    This is for a server so startup is no problem. (-: And I wish that the code gets so popular it has memory problems with the number of plugins... :-)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://963250]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-01-22 00:36 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (60 votes). Check out past polls.