Don't ask to ask, just ask | |
PerlMonks |
Re: perl module structure (Façade choosing backend)by LanX (Saint) |
on Mar 30, 2018 at 10:52 UTC ( [id://1212025]=note: print w/replies, xml ) | Need Help?? |
That's a rather abstract question. More concrete examples would be nice. I was thinking bout examples which do "similar" things, and Term::ReadLine or JSON come to mind, which can switch between different backends. My (maybe naive) approach would be to have a 2 modules for the start, a default implementation Foo::Bar::Standard for fall back and a façade Foo::Bar which exports the API functions which call those standard implementation functions. Something like use Foo::Bar "Other"; would first import the functions of Foo::Bar::Other into package Foo::Bar instead of those from Standard before exporting the interface. Another approach to access the implementation from Foo::Bar is of course to manipulate @ISA. The interface functions would access the implementation by inheritance. I'm sure there are even more OOP patterns to do this and curious to read more replies.
Cheers Rolf
updateYour mention of h2xs is puzzling me. Are you talking about C implementations?
In Section
Seekers of Perl Wisdom
|
|