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

Update: the upload announcement.

I'm trying to help with a common problem that many of us encounter. We have a deadline. We need to implement a feature, but we need to deprecate something (or refactor, or rewrite) but we only have the time to implement the feature if we don't do the refactor. We tell ourselves we'll remember, or put it in our Wiki, or write TODO tests, but those are often overlooked. I propose something like this:

package Customer; use Devel::Deprecate 'deprecate'; sub persist { my $self = shift; my $change_event = shift || $self->change_event; deprecate( { reason => 'Should no longer have an optional change event', warn => '2008-06-12', # or DateTime object die => '2008-08-12', # or DateTime object if => ( scalar @_ ), # optional? } ); ... rest of method }

With this, when the warn date occurs, your test suite starts issuing warnings if the code is still there. Warnings will include the 'die' date, the package and line number.

When the 'die' date occurs, it's a fatal error.

Any issues with this approach? I'm ambivalent about the 'if' condition (you could wrap it if you needed to, but why leave dead code?). Any features you think would be worthwhile?

Cheers,
Ovid

New address of my CGI Course.