Open inpowell opened 2 months ago
It looks like the interface I have settled on is:
MappingTable
Public methods
initialize(...)
print(...)
preprocess(data, ...)
count_aggregate(data, wt = NULL, ..., name = 'n')
get_result_skeleton(...)
get_nullspace(...)
nullspace
(active binding, defaulting to self$get_nullspace()
with no arguments.Protected/private methods
get_input_cols()
get_output_cols()
get_mapping_table(...)
get_by()
get_matrix()
The current implementation for MultiMappingTable
needs basically everything from BaseMappingTable
to be public. The necessary feature would be "friend"-type access, which R6 doesn't support (and likely never will). I thought we'd be able to do something with super
, but that only works for the self
-analogue.
If we really wanted a reduced interface, I can't see a good way to do this other than S4, and I think that's probably not worth it.
Ah that's a shame. I don't think it is a big issue as there are plenty of packages building objects in S3 where everything is just kept in a big list wrapped in an S3 class and the user just ignores the elements they don't need 😄 An alternative could be to create the 'public' options as intended, and create one last public called .Internals
or something that contains everything that the user probably won't need? At least this compacts the resulting object for the user into things they should care about and things they shouldn't.
The interface for mapping tables exposes a lot of implementation details, and I don't want to support them publicly.
Public
initialize()
definitely needs to be publicprint()
must be publiccount_aggregate()
must be public, because that's the functionality we want!preprocess()
is likely only to be used bycount_aggregate()
, so I am leaning towards making this private.Active bindings
map
is only important forcount_aggregate()
. It might need to be extended when implementingdbplyr
backendsmtab
should be available to create an output table skeleton (and allow sorting sonullspace
is in the right order).matrix
is to getnullspace
table_cols
will already be available frommtab
('s replacement)join_clause
is an implementation detail (and I want to change it back to a character type for dtplyr compatibility), so can be made privatenullspace
is a major part of what we need for cell suppression (the only other part being what we want to suppress)Interestingly, private superclass methods are available to subclasses as
private$method()
orsuper$method()
, but private fields are not.