testwhat
testwhat copied to clipboard
Reorganize state classes
(below are rough thoughts)
Classes and SCT dispatching
Currently testwhat keeps a of R6 State classes in state.R
. However, the R6 classes are used only as data containers, while methods are called using S3 method dispatching. This makes it difficult tracking where specific states are used, and what they're being used for. As an alternative, each SCT could
- try calling a method of the same name as the SCT on the R6 class instance (passed as state)
- fall back on a default method (could be to raise an error, etc..)
This way, the methods live on the R6 classes, and the creation of further methods only requires modifying the relevant class.
Classes used once, in a similarly named SCT
Classes like CallState are used once in a corresponding SCT (e.g. check_call). These SCT could be created when the state class has a $check_default
method (or something similar).
I think that's a great idea! You're right that the R6 approach just uses the name of the class to then dispatch the method, but it could be more OO.
@machow that said, the syntax for calling an R6 method is different from the way S3 functions are called. R6 methods are also pretty terrible to debug, AFAIK.
@filipsch that's a really good point. As much as I hate to admit it, the debug-ability of various R classes really affects my willingness to debug things :/.
Solution: just build it right from the start!
Renaming this issue to rewrite testwhat in Julia