Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: What is present best practices for lightweight plugins?

by Rhandom (Curate)
on Apr 03, 2012 at 13:59 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-18 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found