Open PuzzledFace opened 2 years ago
I suggest renaming slots so that the most general term is used as the name for all related slots. So, for example, the DLTintervals
(or dlt_intervals
) slot in CohortSizeDLT
should be renamed intervals
. Where a class contains a "list of subclasses", then the slot should be a simple plural of the corresponding simple slot name - so cohortSizeList
would become sizes
.
CohortSize
Class Current slot name Proposed new slot name
CohortSizeRange cohortSize (cohort_size) size
CohortSizeDLT cohortSize (cohort_size) size
CohortSizeMax cohortSizeList (cohort_size_list) sizes
CohortSizeMin cohortSizeList (cohort_size_list) sizes
CohortSizeDLT DLTintervals (dlt_intervals) intervals
No other changes to slot names.
GeneralModel
Class Current slot name Proposed new slot name
LogisticNormalMixture comp1 components
comp2 components
weightpar weights
LogisticLogNormalMixture shareWeight weights
ProbitLogNormal mu mean
Sigma sigma2
No other changes to slot names. [What about the theta
slot in LogisticKadaneBetaGamma
?
Increments
Class Current slot name Proposed new slot name
IncrementsRelativeDLT DLTIntervals intervals
IncrementMin IncrementsList increments [*]
No other changes to slot names.
[*]: This does introduce one area of potential confusion: the increments
slot in (eg) IncrementsRelative
is a vector of reals, whereas in IncrementMin
it will be a list
of objects.
These are potentially breaking changes. Therefore, users should be given the opportunity to change their code. I propose
/examples
, /R
, /vignettes
and /tests
) and edit all references to the old slotshelp("pkg-deprecated")
For example
.IncrementsRelativeDLT <- setClass(
Class = "IncrementsRelativeDLT",
slots = representation(
intervals = "integer",
dlt_intervals = "integer",
increments = "numeric"
),
prototype = prototype(
intervals = c(0L, 1L),
dlt_intervals = c(0L, 1L),
increments = c(2, 1)
),
contains = "Increments",
validity = v_increments_relative_dlt
)
setGeneric("dlt_intervals", function(x) standardGeneric("dlt_intervals"))
setGeneric("dlt_intervals<-", function(x, value) standardGeneric("dlt_intervals<-"))
setMethod("dlt_intervals", "IncrementsRelativeDLT", function(x) {
.Deprecated(
"intervals",
"crmPack",
"Please use slot `intervals` instead. This slot may be removed in a future version of crmPack"
)
x@intervals
})
setMethod("dlt_intervals<-", "IncrementsRelativeDLT", function(x, value) {
.Deprecated(
"intervals",
"crmPack",
"Please use slot `intervals` instead. This slot may be removed in a future version of crmPack"
)
x@intervals <- value
x
})
To minimise the possibility of conflicts with other development work, I suggest creating issues for each superclass, and making the changes superclass by superclass.
Thanks @PuzzledFace , in the light of prioritizing next CRAN release, and since this anyway breaks almost everything I think... I wonder if we can make this simpler? Without all the deprecation warnings etc.? I guess this would simplify this task a lot
Thanks @PuzzledFace , in the light of prioritizing next CRAN release, and since this anyway breaks almost everything I think... I wonder if we can make this simpler? Without all the deprecation warnings etc.? I guess this would simplify this task a lot
It could be made simpler by just renaming the existing slots. This would greatly reduce the amount of work required. However, this would be a breaking change and I don't think it's a good idea. The who point of the slot "duplication" and deprecation warnings is to make sure that it is not a breaking change: users of the existing slots can use their existing code, but get a warning saying they should update at their convenience.
I firmly believe we should stick with the approach I outlined above.
Thanks @PuzzledFace, generally I agree - however in this case the whole package breaks anyway due to the many changes we did. Therefore I would say in this special case we don't need the deprecation?
Some classes use slot names that are inconsistent within the same hierarchy. For example, slots
size
,sizes
andcohortSize
are all used to denote the size of a cohort in subclasses ofCohortSize
. This is annoying.The following function allows a quick-and-dirty comparision of slot names to be made.
For example ...
... illustrating the point just made as well as showing the use of both
intervals
andDLTintervals
.The outputs from
compare_slot_names("Data")
andcompare_slot_names("Design")
appear uninteresting.compare_slot_names("GeneralModel") %>% select(1:5) %>% print(n=nrow(.))
givesSuggesting that
comp1
andcomp2
(separate slots) are inconsistent withcomponents
(a list) and the use ofweightpar
,weights
andshareWeights
could be rationalised. As perhaps couldmu
andmean
(and possiblytheta
).Also
Sigma
versussigma2beta
andsigma2W
is annoying, both because of the inconsistent case and the absence of the2
.compare_slot_names("Increments")
givesDLTintervals
vsintervals
is a candidate for improvement (if the distinction is important, why notDLTincrements
as well?) and is the upper caseI
inIncrementsList
appropriate (even though it's a list ofIncrements
objects)?compare_slot_names("NextBest")
andcompare_slot_names("Stopping")
appear uninteresting.To do: