The support.bioconductor.org editor has been updated to markdown! Please see more info at: Tutorial: Updated Support Site Editor

Question: Proper way to deprecate an S4 generic
0
gravatar for Michael Steinbaugh
10 days ago by
Harvard
Michael Steinbaugh20 wrote:

What's the current best practice for deprecating an S4 generic? Is something along the lines of this approach recommended?

setGeneric(
    name = "A",
    def = function(object, ...) {
        .Deprecated("B")
        standardGeneric("B")
    }
)

setGeneric(
    name = "B",
    def = function(object, ...) {
        standardGeneric("B")
    }
)

Or should the deprecation call be placed inside an ANY method instead?

setMethod(
    f = "A",
    signature = signature("ANY"),
    definition = function(object, ...) {
        .Deprecated("B")
        B(object, ...)
    }
)
s4 generic • 51 views
ADD COMMENTlink modified 10 days ago by Marcel Ramos ♦♦ 350 • written 10 days ago by Michael Steinbaugh20
Answer: Proper way to deprecate an S4 generic
2
gravatar for Marcel Ramos
10 days ago by
Marcel Ramos ♦♦ 350
United States
Marcel Ramos ♦♦ 350 wrote:

Hi Michael!

First, please make sure that other developers are not importing your generic from your package. You could try the revdep package to check for those https://github.com/r-lib/revdepcheck.

Otherwise, your change could break other packages. Also, if they are using your generic, it would be good to consider moving the generic to another more appropriate package.

But to answer your question, it is better to deprecate the generic in the highest level, inside the setGeneric function (first option). This would ensure that all the methods will get the deprecation message. If deprecate inside the "ANY" method, class-specific methods might not get the message.

Best regards, Marcel

ADD COMMENTlink written 10 days ago by Marcel Ramos ♦♦ 350
1

Thanks Marcel. I've started consolidating my S4 generics into a single pacakge when applicable, similar to the BiocGenerics approach. I'm trying to be extremely conservative deprecating generics, but there are a few edge cases where the verbs aren't quite as clear as another spelling, and I want to be able to redirect users and/or revdeps to that improved variant.

ADD REPLYlink written 10 days ago by Michael Steinbaugh20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 374 users visited in the last hour