Skip to content
Prev 12049 / 21312 Next

[Bioc-devel] R6 class v.s. S4 class

Hi Chunlei,

One thing you could do to make the interface more traditional is to have a
global "query" function that takes a client object as an additional
argument.

Usage would be something like:

gene_client <- BioThingsClient("gene")
query("CDK2", client=gene_client)

To simplify this for common use cases, you could also have query accept
another argument named "type", which is just a string that is passed to
BioThingsClient to construct a new client on the spot:

query("CDK2", type="gene")

And thus the user never needs to interact directly with the client class
unless they need to set some other options besides the query type.
Obviously it should thrown an error if both client and type are passed.
Additionally, for interactive use, it might be useful to define an option
to set the default client to use if none is passed, e.g.

options(default.biothings.client = BioThingsClient("gene"))
query("CDK2")

Lastly, if you go this route, you will probably want to pick a more
specific name for the query function, this design makes it globally visible
rather attached to an object. More generally, all the function/argument
names I've provided are just example names.

Anyway, I'm not very experienced designing object-oriented interfaces in R,
but that's my 2 cents from a user perspective of how I would expect such an
R package to work. Hopefully others with more class design experience can
provide additional advice.

-Ryan
On Thu, Oct 19, 2017 at 5:25 PM Chunlei Wu <cwu at scripps.edu> wrote:

            

  
  
Message-ID: <CAHCt_abNdizEDUg3zpOX=YWaV0ScRVSuwaMz5LanQMFrdpUCqQ@mail.gmail.com>
In-Reply-To: <CY4PR11MB14008C7C89B07264BD2A4251B9430@CY4PR11MB1400.namprd11.prod.outlook.com>