Skip to content
Prev 12078 / 21307 Next

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

As the developer of all these three biothings_clients, we, of course, like to keep the same pattern for R, and R6 looks the closest to me. But it looks like, from R users' perspective, this is not a popular pattern to use

Yes, there will probably be way more users of R wanting to use BioThings than BioThings users wanting to use R.

Chunlei: That'true, so we think a native R client would be appreciated by R community. And also yes, it's pretty light on the code, but it's important to design it correctly.




Then in R, we will have to create these generic methods (hope this is the right term):


getBioThing(mything_client, ...)

getBioThings

As Herve points out, R users will expect queries to be vectorized implicitly. queryBioThings() or whatever should probably return a tabular structure describing the things. There is no need for distinguishing singular and plural.

Chunlei: Good suggestion! We will see if we can wrap these two functions into just one. Maybe we can have just BTGet and BTQuery two functions, that seems much cleaner.



queryBioThings

queryManyBioThings

BioThingsMetadata


I personally still like the Python/JS pattern, as you can have client specific name like "getgene", "getgenes", instead of the generic getBioThing and getBioThings name. Plus that users can just call "gene_client" part as "gc" or whatever, it just has much less to type :-) in the code. In R S4 case, the function name has to be more verbose because they are global.


There seems to be a misconception here. S4 has two types of classes, conventional value classes, and reference classes. The reference classes have the same syntax as the R6 classes. R6 is mostly a stripped down version of S4 reference classes. In this particular case, R is sufficiently flexible that it would be easy to support the reference class syntax on ordinary value classes. So you could use the reference class syntax, but I wouldn't recommend it, for the aforementioned reasons. Moreover, be careful about carrying over notions from Python and JS into R. R is unique in fundamental ways.

Chunlei: Thanks for clarifying. As a non-regular R user, I understand (and also respect) more and more the significant difference between R and many other general-purpose languages now. The help from this group has been great!



Does this sound good to the group? Any more suggestions?


Chunlei
Message-ID: <CY4PR11MB1400520CCB22B07EF5226CE1B9430@CY4PR11MB1400.namprd11.prod.outlook.com>
In-Reply-To: <CAOQ5Nye70nXrvuYcRHQfd23FQW_2Ta4BOmHB35YiT3hTiiOaSA@mail.gmail.com>