Open adamsardar opened 5 years ago
Hadley's Advanced R book discusses the problem:
https://adv-r.hadley.nz/oo-tradeoffs.html#threading-state
Much like the pop
example, we want to call a function and then save the updated state somewhere. A functional approach is to create a fresh state (and leave the original unchanged) - remember, Immutability . An object has the state intrinsically with methods.
Expanding on the previous Julia package: the reason that it felt like a mess was that the initialiser function created ALOT of state. Nothing felt easy.
More and more I am coming around to the thinking that this should go to CRAN
Being a computational biology package, Bioconductor would seem sensible. BUT, there is an emphasis on S4 methods, rather than R6.
An advantage of S4 is that the dispatchers are typed (so the input validators would not be necessary). Also, documentation of S4 is more natural with roxygen, which would make #4 easier.
A disadvantage is that the process is well suited to an object - there is explicit state. A previous incarnation of the package was in Julia (whose object system is a lot like S4) and that was a total mess.