One way you could do this is to never use other modules directly, but to have intermediate modules in between.
Something like this:
YourCode.pl--YourInterfaceModule.pm--ChangingModule.pm
So you create a stable interface towards your code, and when the interface breaks to the foreign modules, you've got one place to change the code, in YourInterfaceModule.pm.
Maybe there could be some kind of naming convention, so that when you want e.g. the functionality of Mail::POP3Client.pm (which according to the docs will change in that it will enforce named parameters in the future), you actually use your own module "MyInterfaces::Mail::POP3Client.pm", and then that module soaks up any interface changes.
update: I just realised that somebody with the right knowledge could create a generic module with:
- A slot for the object you really want to reach
- Some AUTOLOAD magic to forward any method calls to the object in that slot
- Then just write subs (methods) to handle interface changes
This could work something like this:
package MyInterfaceTo::The::Real::Module
use InterfaceModule ("The::Real::Module");
# InterfaceModule will handle method calls that fall
# through, i.e. a bit like Class::MethodMaker
# That would be all coding needed, as long as there
# are no interface changes. When something changes, just
# drop in a sub:
sub get_some_data {
# Changed from param list to named params
my $self = shift;
my %param;
$param{'shoe_size'} = shift;
$param{'shoe_color'} = shift;
$param{'shoe_type'} = shift;
$self->object_slot->get_some_data(%param);
}
1;
update II: After looking at TheOtherGuy's reply it became clear that the problem the fancy generic-interface-module I suggested above tried to solve, can be solved with less effort by just subclassing the module in question, of course (looking at the code now I realise: "Oh, I just reinvented inheritance!":-). However there was a deeper train of thought behind it: The generic-interface-module approach can be used to switch implementation (what module to use). If this is done at run time it would change it from an adapter to a factory, if I got the patterns in the Gamma book right.
/jeorgen |