testwhat icon indicating copy to clipboard operation
testwhat copied to clipboard

Reorganize state classes

Open machow opened this issue 7 years ago • 5 comments

(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

  1. try calling a method of the same name as the SCT on the R6 class instance (passed as state)
  2. 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).

machow avatar Jan 09 '18 21:01 machow

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.

filipsch avatar Jan 10 '18 09:01 filipsch

@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 avatar Jan 11 '18 01:01 filipsch

@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 :/.

machow avatar Jan 11 '18 14:01 machow

Solution: just build it right from the start!

filipsch avatar Jan 11 '18 15:01 filipsch

Renaming this issue to rewrite testwhat in Julia

machow avatar Jan 11 '18 15:01 machow