http://www.perlmonks.org?node_id=468852

jacques has asked for the wisdom of the Perl Monks concerning the following question:

Recently I have been contemplating changing the namespace for one of my modules, and I was reminded of once reading that the HTML::Mason team is considering the same thing.

How is it best to handle a namespace change? Should I release an updated module version whose sole purpose is to install the renamed module in the new namespace on CPAN? How should I accomplish this in the Makefile?

Replies are listed 'Best First'.
Re: Changing a module's namespace on CPAN
by kirbyk (Friar) on Jun 21, 2005 at 23:33 UTC
    Since this requires users of your code to change their code, I would avoid making it not obvious what has happened.

    You could replace the old namespace functions with wrappers that call the new functions for backwards compatibility - but then, what have you ultimately gained? Two things to update instead of one.

    With things like these, just do it, tell people that the old code is deprecated (especially in the perldoc and on CPAN) and leave it up to them if they ever want to upgrade and fix their code, and then ignore the old version.

    -- Kirby, WhitePages.com

Re: Changing a module's namespace on CPAN
by PodMaster (Abbot) on Jun 22, 2005 at 00:29 UTC
    Recently I have been contemplating changing the namespace for one of my modules
    Why?
    How is it best to handle a namespace change?
    By not changing the namespace (picking a good one to begin with) :)
    Should I release an updated module version whose sole purpose is to install the renamed module in the new namespace on CPAN?
    Technically, that's the only way to "rename" a module, by releasing a new module with a different name. But if thats all you're going to do, you really shouldn't. But, if you insist on doing it, make sure you release a final version under the old name, making it clear to its users that the name has changed, and what kind of support they can expect...

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Why?

      Sometimes things change, and modules evolve beyond their original intention. I don't think it happens often, but I know that the potential for it to happen exists.

Re: Changing a module's namespace on CPAN
by qq (Hermit) on Jun 22, 2005 at 04:58 UTC

    Release a new module. If it contains substanitially more functionality, keep the backward compatible API distinct.

    Old::Module becomes New::Module New::Module::OldModCompat

    Then update the old module, addind text referring to the new module, and saying that the old will receive no further maintenance work. Don't remove it.

    And think very carefully about the new modules name!

Re: Changing a module's namespace on CPAN
by dynamo (Chaplain) on Jun 22, 2005 at 04:42 UTC
    I'd do the new module with the new name, and the wrappers; as previous posters have suggested, and THEN ignore the old stuff. At least with the wrappers, users of the old API have a chance of being able to use your new functionality. If you change the new API, having the wrappers be made for a slightly different API is a whole lot more helpful than not having them at all, for people with the old code who might want to update the wrappers for you. I think it's worth doing in the first place.
    - paul
Re: Changing a module's namespace on CPAN
by cog (Parson) on Jun 22, 2005 at 10:56 UTC
    Been there, done that.

    What I did was to release the new module and a new version of the now deprecated one, with only one change: a note at the beginning, stating the module would continue to evolve in the new namespace.

    I think it worked out OK.

      What modules (old and new one) are those?
        Date::Holiday::PT changed to Date::Holidays::PT (internationalization issues, and yes, there were some people using that module).

        Lingua::Identification changed to Lingua::Identify (but I can't seem to find the first one on my backpan, so I guess by that time I had it only in my homepage; and yes, people were using it too).

        This last one also had a considerable API change, at some point (and a big internal change, too).

        One last thing regarding namespace/API changes: do it as soon as possible! :-) The least users you have the easier it gets! :-)

Re: Changing a module's namespace on CPAN
by techcode (Hermit) on Jun 22, 2005 at 08:57 UTC
    I'm not (even near) expert on this matter. And I'm also curious about a solution.

    How about making new version of that old module, specifying that it's name changed to xxx and that anyone who wants to use it, should use the new one from now on. Put that as first thing in the docs.

    And change code to something like

    package Old::Module; use base 'New::Module'; 1;
    Would that do the trick? Actually when I think about it. If module is written with inheritance in mind (and since you're rewriting it anyway, you can add it if needed) that should work perfectly. And people could even continue to 'use Old::Module;'.

    But then again, what's the point? Probably the new name is/will describe better what module does, and where it belongs (folder/namespace)...