[Bioc-devel] implementing interfaces

Robert Gentleman rgentlem at fhcrc.org
Tue Nov 25 22:08:57 CET 2008


Martin Morgan wrote:
> James Bullard wrote:
>> hi all, this will probably demonstrate my lack of knowledge concerning
>> OOP in R, but I am hoping for some quick answers. This is a problem I
>> have faced before.
>> I want to use the method bg.correct.mas, this method takes as its
>> object an AffyBatch. I don't have an AffyBatch nor do I want to
>> massage my data structures into such an object, so I want to implement
>> the AffyBatch interface. However, I can see no way to determine the
>> list of generics which have methods defined on AffyBatch (and
>> superclasses). I understand that things are method-centric, however I
>> assume that being method-centric still leaves room for a way to know
>> the methods specialized for a class/interface so that I as a
>> programmer can define the suitable methods on a new class without
>> having to dig around all over the place determining what I need to
>> define. My question is:
>> is there a function to determine all the methods that are specialized
>> for a certain class? Also, would it be possible to write a function
>> adheresTo(classA, classB), which tells me that classB satisfies the
>> calling requirements of classA (forget for a moment that we have
>> public member variables).
>> note, i don't want to make a subclass of AffyBatch.
> showMethods(class="AffyBatch")
> gets you some of the way there. But in a brand spanking new session it
> shows nothing (because the packages where methods are defined, e.g.,
> affy, has not been loaded) and this illustrates a fundamental problem:
> the interface to AffyBatch is dynamically determined by loaded packages.
> Likely you'd invoke
> showMethods(class="AffyBatch", where=getNamespace("affy")
> to get a kind of base-line set of expected methods, i.e., those visible
> from affy.

  But this all seems like a weird way to go.  I guess I don't really see the use
case for:
  I know this class (AffyBatch), and I want to find all generics that have
methods for it, so I can implement my own class and the same set of methods.

  Why not figure out what operations you think you want to support, and support
those? What is so special about the set of generic functions that have AffyBatch
methods that you would want to support those?

  And then, typically the simplest way to get there is to define a coerce
method.  I know you say you don't want to do that, but basically, if the class
(AffyBatch) is widely used (I mean here that lots of methods are defined for it,
not that people use it) that exercise its components you will need to have a
class that is basically isometric to it, and then why would you want the
additional code base that comes with having your own methods?

> AshowMethods returns a connection (!) which is basically useless for
> programmatic purposes, e.g., adheresTo().

  true, but you can get a slightly (only slightly) more helpful answer if you
set printTo=FALSE (in a recent revision of R 2.9.0 candidate)


> Martin
>> thanks, jim
>> _______________________________________________
>> Bioc-devel at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/bioc-devel

Robert Gentleman, PhD
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
PO Box 19024
Seattle, Washington 98109-1024
rgentlem at fhcrc.org

More information about the Bioc-devel mailing list