Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question:
Hello esteemed monks,
Say I have a CPAN module and I found out that its behavior is not exactly optimal. So I would like to change it, but there may be users out there! How do I change my module before backward compatibility locks me into my bad decisions? And what modules should I look into that do the right thing (tm)?
My current policy is to keep old behavior with a deprecated warning for 5 releases (not including the bugfix), but I guess that's not the best I can do.
Thank you.
Re: Sane deprecation policy for a CPAN module?
by stevieb (Canon) on Nov 17, 2018 at 14:43 UTC
|
You say that the "behaviour" isn't optimal, but you don't clarify whether the actual interface is a problem or not.
Is "behaviour" what's happening behind the scenes that if you change it, it'll affect the interface the user uses or the results/returns/output? If not, make the changes, make sure all existing tests pass, write new tests, and you're good to go.
Otherwise, if the user experience will change, as LanX said, you have a few options:
- Write a brand new distribution, deprecate the old. In the old one, point loudly to the new one for new users
- Add new functions/methods alongside the existing ones that are already in use. Deprecate the latter ones, leave them for back-compat, but promote the new subs for new users, and existing users who may one day update their own software
- Add new flag(s) to the existing subs, so that the different "behaviour" is called behind the scenes if the user sets this flag.
I'd stay away from the last option though, as personally I see it only as a stop-gap for a transition into something new. It'll add complexity to the already inefficient behaviour you've already got.
As far as time frame, I'd give at least one year for providing critical updates (security, data corruption etc), then at that time, change the notice from deprecated to unmaintained.
| [reply] |
|
| [reply] |
Re: Sane deprecation policy for a CPAN module?
by LanX (Saint) on Nov 17, 2018 at 11:51 UTC
|
My preference is to keep the old code for backwards compatibility and flag it as unsupported.
Either by expanding the API in the same module, or by writing a new one.
Sorry. Maybe not what you wanted to hear. :)
| [reply] |
|
This is definitely the best option.
However, we'd run out of CPAN namespaces though if authors start renaming modules upon realizing they made a poor design decision in the past.
Which begs the question: how to minimize the damage from a possible bad decision in the first place? I think there should be some rules of thumb.
| [reply] |
|
| [reply] [d/l] |
|
|
> I think there should be some rules of thumb.
In open source we should rather talk about habits and culture, if there are rules they developed from tradition.
> how to minimize the damage from a possible bad decision in the first place?
Flag your module as experimental, till its implementation is fixed.
Or contact the users, if there are no reverse dependencies you should be fine.
> we'd run out of CPAN namespaces
Not if you keep the old API for a deprecation period.
For instance you could refactor the "bad" part of module XXX to XXX::Old, and use it internally.
Or new users need a use XXX :modern attribute or version number during a grace period.
You should know best what is feasable!
Sorry, I'm not aware of any policy which will safe you from being called names by old users if you break their code, even after warning them for years.
It's up to you. .. :)
Just have a look at CGI.pm
| [reply] [d/l] |
|
|
Re: Sane deprecation policy for a CPAN module?
by kcott (Archbishop) on Nov 17, 2018 at 20:26 UTC
|
G'day Dallaylaen,
[Note:
It is unclear from your post whether the deprecation warnings are from your own or third-party CPAN module(s).
If the former, some of what follows may not be pertinent.]
You wrote about "... backward compatibility ...";
however, you also need to consider forward compatibility.
If you search perldiag, you'll find entries containing text like:
"... is deprecated, and will disappear in Perl 5.xx ... (D deprecated) ..."
"Deprecated ... This will be a fatal error in Perl 5.xx ... (D deprecated) ..."
"... (F) ... was deprecated in Perl 5.xx, and became fatal in Perl 5.yy."
When you use modules,
you can specify a minimum version for those modules.
You can also specify a minimum Perl version with use.
Also see the no function.
The if pragma
can be used to conditionally load modules based on the current Perl version.
(Its conditions are not limited to this type of check.)
In your Makefile.PL, you can specify a minimum version for both Perl and dependent modules:
see ExtUtils::MakeMaker.
Module::Build offers similar facilities.
Provide clear documentation.
Obviously, this will depend on how you end up handling this.
You might provide a final end-of-life version of X::Y::Old
with doco recommending changing to X::Y::New.
You might update the current module with doco explaining why this version is preferred.
Use POD and the README, INSTALL and Changes files as appropriate.
I'd recommend using cross-references (e.g. "See the INSTALL file for details.")
rather than copy/pasting tracts of doco from one place to another
(which will almost invariably end up getting out of sync).
| [reply] [d/l] [select] |
Re: Sane deprecation policy for a CPAN module? (Software Versioning References)
by eyepopslikeamosquito (Archbishop) on Nov 18, 2018 at 20:43 UTC
|
Thanks for asking this -- it reminded me I need to update Writing Solid CPAN Modules with advice on CPAN Module Versioning.
Short Summary
For a new module, start by adding the line:
our $VERSION = '0.01';
near the top of the file (shortly after the module's package statement).
Note that our was introduced in Perl 5.6.0.
If you need to support Perl versions earlier than that, use instead:
use vars qw($VERSION);
$VERSION = '0.01';
With that done, simply bump up the value of $VERSION as you add new features; for example '0.01', '0.02', '0.03' and so on.
When you have finally produced a stable, production quality API, on which users have come to depend, it is a good idea to indicate that by bumping the module version to '1.00' or higher.
And further to set your CPAN distribution's CPAN::Meta::Spec's release_status to "stable" (other values for this piece of CPAN distribution metadata are "testing" and "unstable").
General Software Versioning Refs
CPAN Versioning Refs
- perlmodinstall - Installing CPAN Modules
- CPAN::Meta::Spec by xdg - specification for CPAN distribution metadata, see especially release_status field (with values 'stable', 'testing', 'unstable').
- perlmodlib : see "Guidelines for Module Creation" section. From that section: "To be fully compatible with the Exporter and MakeMaker modules you should store your module's version number in a non-my package variable called $VERSION. This should be a positive floating point number with at least two digits after the decimal (i.e., hundredths, e.g, $VERSION = "0.01"). Don't use a "1.3.2" style version. See (Module Version Checking) in Exporter for details". From the "Version numbering" sub-section: "The most common CPAN version numbering scheme looks like this: 1.00, 1.10, 1.11, 1.20, 1.30, 1.31, 1.32".
Note: apparently Perl Best Practices got this wrong (in Modules chapter, 221. Use three-part version numbers; 222. Enforce your version requirements programmatically) and so is a dubious reference on CPAN module versioning.
See also:
META.yml and META.json
Some Perl Monks Versioning Nodes
Deprecating a CPAN module
- XML::XSH by choroba - There is a big warning right at the top "This module is deprecated, use XML::XSH2 instead".
- XML::XSH2 by choroba - This is the current one. Looking forward to XSH3, XSH4, XSH5, ... :)
- Hmmm, CPAN::Meta::Spec does not appear to have a Deprecated status, release_status has only "stable", "testing", "unstable".
Perl Monks Nodes Added Later
Note: Many updates were made long after the original reply - in preparation for later insertion into Writing Solid CPAN Modules
| [reply] [d/l] [select] |
|
Well at least I got my version numbers right, apart from skipping x.y0 which I'm going to take up now.
| [reply] |
|
|