With regard to R Reference Classes, if we override the default $initialize()
constructor, which is considered better practice to initialize fields: $initFields()
or $callSuper()
?
I've considered a few pros/cons:
If the default behaviour of
$initialize()
is changed/extended in some future version of R,$callSuper()
will reflect those changes without having to add/rewrite codeThere's nothing stopping you from calling
$callSuper()
twice in a single$initialize()
. Is it officially documented/well-defined what happens in such a scenario?