in reply to Re^4: Upgrade-proofing overridden subroutines
in thread Upgrade-proofing overridden subroutines

If what the code is currently doing is not a problem, then you don't have a problem, do you?

I think you misstated something here. I guess you are trying stress your vexation anticipating his fix clobbering your fix and that that future is not coming soon enough. This indicates a basic trust issue with the code you are using. You imply the module doesn't have versions, if it does, don't waste time generalizing your solution. Instead, for the modules you care about, report the bug of lack of versions. You need to be able to divine the version of things to maintain the control/quality/efficiency standards which you seek.

Within the limitations he describes, adrianh's solution is suited to your problem.

What are the problems with forking? If you have hope that the author will be back someday, you can do it quietly by renaming the packages and distributing them within your distribution. So long as you hope, you treat the code as if it were still under its author's care. If he wakes up or comes back or finds time, you can refactor the code easily at your convenience. If it turns out the code is abandoned, it will be nice that you kept it alive.

Be well,
rir

  • Comment on Re^5: Upgrade-proofing overridden subroutines

Replies are listed 'Best First'.
Re^6: Upgrade-proofing overridden subroutines
by Ovid (Cardinal) on Aug 16, 2006 at 08:25 UTC

    I was meaning "what the code is currently doing" in the context of Adrian's suggestion that it could be safe to run a sub to know if it behaves correctly. That way I could always run the code after an upgrade to see if its behavior has changed. The problem with that is even if I know what the code is currently doing and therefore deem it safe to run, I don't know what it will be doing in the future, and thus I don't know if it will be safe to run. Thus, Adrian's solution can't work.

    As for the problems with forking, you can google for that pretty easily. The pros and cons are numerous and well spelled out. To fork, you really need a compelling reason to but too many forks spoil the broth. Even a great fork can meet serious resistance. Look at Module::Build. Many people who didn't understand the problems with ExtUtils::MakeMaker were pretty vehement that Module::Build was a bad thing. Go figure. (well, there was that little matter of PREFIX. It's horribly broken but people want its broken behavior).

    If you fork privately, you have to maintain it in-house. For small projects this is not so bad. For large projects, it gets hairy. If you want to fork it publicly, you might get community support. You might get ingnored. You might get community derision. Imagine if Module::Build was one of the offenders (it has bugs reported, but it's certainly not one of the offenders in question since it's being so actively developed). Could you reasonably fork that and expect it to work on the hundreds of different platforms it's supposed to work on? Could you expect the community to help with a fork they may not see the merit of?

    That's not to say that forking is always bad. I'm just pointing out that forking is a very serious issue and if the code isn't trivial, it shouldn't be done on a whim.

    Cheers,
    Ovid

    New address of my CGI Course.

      Update: Added output of sample code.

      I apologize--I feel like I took your question too concretely, that I missed a modest mentoring tone in your first post, and that I provoked you to the defense of your module. You tossed out Module::Build as if it were germane when we were talking about neglected modules. That seemed red-herringish to me; did I miss a point?

      If you fork privately, you have to maintain it in-house.

      The wisdom I was trying to share:

      • You are already maintaining this code and you should not deny it just because it is an unpleasant reality.
      • There is no real protection against future changes in not-invented-here code.

      Adrianh's solution, if usable, has the advantage of clarity.

      For readability and lack of any downside of which I can think, my first choice for an outside patch would be to redefine the problem.

      use Foo; package Foo; { no warnings "redefine"; sub foo { 'different foo' } } package resume_former_namespace; ...

      I like the idea of aliasing away the problem but I can see how that could be very confusing to those year-later-and-you're-gone maintainers. It is not really possible to predict what semantics those folk will expect. Should foo or Foo::foo be overridden in below? I'd avoid that issue unless I need the flexibility.

      Be well,
      rir

      #!/usr/bin/perl use warnings; use strict; use Foo; use Sub::Override; sub fixed_foo { "I'm overridden foo" } my $override = Sub::Override->new; $override->replace( 'Foo::foo' => \&fixed_foo ); # maybe 'foo' print "Foo::Ridden: ", Foo::foo(), $/; print "Foo::Ridden: ", Foo::bar, $/; print " ::Ridden: ", foo(), $/; $override->restore; print " ::Orig: ", foo(), $/;
      File Foo.pm
      package Foo; use Exporter; our @ISA = 'Exporter'; our @EXPORT = qw/ foo bar /; sub foo { "I'm foo" } sub bar { foo() . 'bar' } 1;
      Output of above code overriding Foo::foo.
      Foo::Ridden: I'm overridden foo Foo::Ridden: I'm overridden foobar ::Ridden: I'm foo ::Orig: I'm foo
      Results of same code overriding foo.
      Foo::Ridden: I'm foo Foo::Ridden: I'm foobar ::Ridden: I'm overridden foo ::Orig: I'm foo
      ~

        Whoa! That's something I hadn't thought about. Thanks for bringing it to my attention. Yes, it will likely confuse people and that's probably something I should add to the docs.

        Cheers,
        Ovid

        New address of my CGI Course.