waldronlab / bedbaser

An R client for bedbase.org
1 stars 0 forks source link

Changing the API to use reference classes? #10

Open nsheff opened 1 month ago

nsheff commented 1 month ago

Given that the BEDbase() object is a client that connects to a server, it seems to me that this is an appropriate use of a Reference Class, because we don't really need duplicates of this object; we just need 1 client and then whatever functions use it can just use that.

It also makes more sense to me for the user to do something like this:

bb <- BEDbase()

bb$list_beds()

Rather than the current approach of passing the api in to the functions, like bb_list_beds(api).

This has the advantage that I can type bb$ ... and then tab complete and get REPL feedback as to what methods are available.

Maybe this is less idomatic for R, but I find this approach more intuitive and I think reference classes made this approach possible. Would love to hear your thoughts.

So I think the 2 advantages of using reference classes would be:

but I'm not super confident in all these things, so it's just an idea for consideration/discussion.

jwokaty commented 1 month ago

I see your points and I headed down this path initially when I was writing bedbaser before it quickly became complicated for a handful of convenience functions I created in the package. I'll give it more thought but I am reluctant to change it close to the release when it's also in review, even though it would mean deprecating things later.