Closed Bug 283244 Opened 20 years ago Closed 18 years ago

Way to indicate deprecated functions in the code

Categories

(Bugzilla :: Bugzilla-General, enhancement)

2.19.2
enhancement
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: mkanat, Unassigned)

References

(Blocks 1 open bug)

Details

I think it would be nice to have a standard way to indicate that certain functions are deprecated, so people don't use them anymore. I think the best way would be through perl's "attributes." We could have an attribute called "deprecated." So a deprecated function definition would look like: sub func ($$) : deprecated { ... } We could also have what it's deprecated in favor of in the attribute, like: sub new_from_login ($) : deprecated("new Bugzilla::User(login_to_id($name))") { ... } The nice thing about attributes is that at some point we could start throwing warnings for every use of a deprecated function, or do whatever we want with them. It would also clearly indicate to developers that they shouldn't use that function in new code. Right now, I think that developers use and review+ use of deprecated functions because we have no way of standardly indicating that a function is deprecated. Also, it's sometimes hard to know what we should be using instead, when we're so used to using the old function. The alternative to the solution above would be to have a standard in the POD docs for indicating that certain functions are deprecated.
> Right now, I think that developers use and review+ use of deprecated functions > because we have no way of standardly indicating that a function is deprecated. the biggest problem i have with respect to deprecated functions is where new code is added to an existing routine that already uses deprecated functions. should we require _all_ new code to use the current functions, which will result in the same sub using SendSQL and $dbh (for example)? regarding attributes, they look like a good idea, however we should do both attributes and pod docs. more importantly we need to ensure that decisions are sent to the developers and reviewers list. for example at some stage using prototypes switched from being bad to good, however this was never announced. how about we create a test that throws warnings for each deprecated function?
As far as writing new code that uses deprecated functions, it really depends. If you're creating brand-new code inside of an old subroutine, then yeah, you should make it use $dbh even if the rest of the subroutine is using SendSQL. However, it's OK to *touch* a line of code and leave a deprecated function there, if it has nothing to do with your patch, in the interest of focused patches. The test is also a good idea, but we'd have to make sure that it didn't turn the tinderbox orange, because there's a LOT of deprecated functions right now.
I think this isn't necessary anymore, now that we don't have CGI.pl and globals.pl.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.