[Bioc-devel] avoiding clashes of different S4 methods with the same generic

Aaron Lun alun at wehi.edu.au
Wed Apr 27 11:03:51 CEST 2016


> OTOH introducing a "straight" subclass only to define one specialized
> method on it (the "normalize" method in this case) might not be worth
> it since there is a cost for such class, even if that cost is minimal:
> a cost for the user (one new container/constructor to deal with) and a
> cost for the developer (e.g. multiplication of coerce methods).

On the plus side, a straight subclass would make it easier to solve the 
same problem for other generics. For example, let's say that csaw and 
swings both defined the estimateDispersions() method for the SE class. 
If we decided to use dual dispatch, then the estimateDispersions() 
generic would also have to be changed to have an additional argument. 
This would not be necessary if the two packages set up their own 
straight subclasses and defined S4 methods for each subclass.

It is slightly annoying, though, to have to define something like a 
csawDataSet class and its constructor, even if the constructor is just a 
trivial wrapper around the SE constructor. Ah well.

> [Interestingly the scran package defines a default "normalize" method
> (i.e. a normalize,ANY method)].

Yes - uh - I got too excited with S4 methods, and things got out of 
hand. I've been pruning out some of the sillier definitions.

- Aaron


> On 04/26/2016 03:03 PM, Aaron Lun wrote:
>> Yes, but "monkeyBars" doesn't have quite the same pithiness for a
>> package name.
>>
>> Anyway, the dual dispatch mechanism sounds most interesting. I assume
>> that means we'd have to define some sort of base "normalizeParam" class,
>> and then derive "csawNormParam" and "swingsNormParam" subclasses, so
>> that specific methods can be defined for each signature.
>>
>> - Aaron
>>
>> Martin Morgan wrote:
>>>
>>> On 04/26/2016 05:28 PM, Michael Lawrence wrote:
>>>> On Tue, Apr 26, 2016 at 2:16 PM, Martin Morgan
>>>> <martin.morgan at roswellpark.org>  wrote:
>>>>>>
>>>>>> On 04/26/2016 04:47 PM, Michael Lawrence wrote:
>>>>>>>>
>>>>>>>> On Tue, Apr 26, 2016 at 11:00 AM, Aaron Lun<alun at wehi.edu.au>
>>> wrote:
>>> ...
>>>>>>>>>> BiocGenerics. However, if some other hypothetical package
>>> (I'll call it
>>>>>>>>>> "swings", for argument's sake) were to define a normalize()
>>> method with a
>>> ...
>>>>>> I like the dual dispatch method quite a bit (but wonder why we get
>>> several
>>>>>> swings but only one csaw? Maybe a csaw implies two participants
>>>>> [though I
>>>>>> think I once in a while csaw-ed alone], so a singular csaw and a
>>>>> pair of
>>>>>> swings balance out?), partly because it's very easy to extend
>>>>> (write another
>>>>>> method) and the second argument can be either lightweight or
>>>>> parameterized.
>>>>>>
>>>> I could go along with the dual dispatch. "Swings" is short for "Set of
>>>> swings". Usually, there are several swings in a row, but only one
>>>> see-saw.
>>>>
>>>
>>> Googling for "how many swings per see-saw" took me to
>>>
>>>    https://www.cpsc.gov//PageFiles/108601/playgrnd.pdf
>>>
>>> where it is apparent that swings are much more dangerous than see-saws
>>> (e.g., 51 matches for "swing" versus 4 for "see-saw"; "Swings ... were
>>> involved in about 19 ... percent of injuries ... See-saws accounted
>>> for about three percent"; "Homemade rope, tire, or tree swings were
>>> also involved in a number of hanging deaths" [no mention of death by
>>> see-saw]).
>>>
>>> I think for the sake of our users, especially our younger users, we do
>>> not want to consider swings, or even methods on swings, further.
>>>
>>> Martin
>>>
>>>
>>> This email message may contain legally privileged and/or confidential
>>> information.  If you are not the intended recipient(s), or the
>>> employee or agent responsible for the delivery of this message to the
>>> intended recipient(s), you are hereby notified that any disclosure,
>>> copying, distribution, or use of this email message is prohibited.  If
>>> you have received this message in error, please notify the sender
>>> immediately by e-mail and delete this email message from your
>>> computer. Thank you.
>>
>> _______________________________________________
>> Bioc-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>>
>



More information about the Bioc-devel mailing list