Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Gracefully Downgrading Behavior

by gaal (Parson)
on May 10, 2007 at 09:15 UTC ( #614580=note: print w/replies, xml ) Need Help??


in reply to Gracefully Downgrading Behavior

(Here be plugs.)

When there are several providers of the functionality that have compatible APIs, you can use Best. With modules that just export functions, you simply replace the use line:

use YAML; # This module is slow! # So if you want to try a faster one first: use Best qw(YAML::Syck YAML); print Dump({ some => 'hash' }); # Dumping provided by Best Possible YA +ML module

There's knobs you can use to rewire stuff as in your is_deeply example; and a which function is provided so you can get the name of the module that was actually loaded to write factories with.

use Best qw(OOPishProv AnotherOOPyProv::Serving::As::Fallback); my $obj = Best->which("OOPishProv")->new;

If you're out for less syntax, you might like to try the possibly too-magical Class::TransparentFactory.

Replies are listed 'Best First'.
Re^2: Gracefully Downgrading Behavior
by Ovid (Cardinal) on May 10, 2007 at 09:34 UTC

    So you're recommending that I have users install another module so that they don't need to install another module? :)

    Cheers,
    Ovid

    New address of my CGI Course.

      Nah :-) This is addressed in the docs. Basically just stick the tiny Best.pm file in your lib/, or Inline::Module it (maintainer action; the user need not have I::M installed).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://614580]
help
Chatterbox?
[1nickt]: I will not convince anyone who disagrees with me, with a sticker. And I don;t need to advertise my thoughts, really.
[Discipulus]: ++1nickt but what about: "out immigrants! just redskins!"
[1nickt]: I know what I believe and whether I have integrity. My actions will speak more.
[karlgoethebier]: choroba Nothing unclever in my sig. And remember: Beeing too clever is a bad mistake ;-)
[1nickt]: This is not to suggest that Karl should remove his slogan. Just thoughts of mine... Trust me I believe I am very much more radical than most, and if I had a slogan for every gross injustice in my sig, there would be no more bytes!
Discipulus redskins .. well native american..
[1nickt]: So if I was to offer any editorial advice it would be to (1) make it endure time passing (2) make it positive (3) make it about you and your beliefs
[1nickt]: (Disicpulus The new best choice is maybe "First People"
[karlgoethebier]: Discipulus: This is called "Volksverhetzung" in German which means
[karlgoethebier]: incitement of the people and it is prohibited by law

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2017-06-22 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (519 votes). Check out past polls.