Problems? Is your data what you think it is? | |
PerlMonks |
Re: Creating a "Plug-In" Framework for a Moduleby g0n (Priest) |
on Jan 30, 2006 at 14:49 UTC ( [id://526457]=note: print w/replies, xml ) | Need Help?? |
One method I've used for handling plugins (thanks to the guidance of various monks in the CB) is a delegation class - something like this:
(With similar methods for all the other function calls needed). Then at run time you can choose which implementation class to use, or take the default ('Toolkit::FileDB' in this instance). Update: It's just occurred to me - that way you could also create stubs for the functionality that return 'this function is not available without X::Y::Z installed' instead of a fatal error. Update: There's some possibly related discussion about using use and require in Use and Require - making an informed choice.
-------------------------------------------------------------- "If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing." John Brunner, "The Shockwave Rider".
In Section
Seekers of Perl Wisdom
|
|