Stage classes should only have 0-arg constructors
Description
Environment
Activity

Ian YoungApril 20, 2023 at 5:00 PM
Note that the one-arg constructor is deprecated, and has a DeprecationSupport
warning. I’ve made a point of saying in the release notes that this will be removed in 1.0.0.

Ian YoungApril 20, 2023 at 4:59 PM
Done, commit 97686fd8daccb2359d051613f0a1421beca9d387.

Ian YoungApril 20, 2023 at 4:04 PM
It turns out that GenerateIdStage
is the only case.

Ian YoungFebruary 1, 2023 at 10:56 AM
I’m trying to recall the original reasoning behind this. Part of it was certainly consistency (most Stages are like this, so all of them should be) but I think that original push originally came from the IdP and the business with constructor names being a little weird in Spring, for which we now use a custom annotation and may also need to use the javac -parameters
longer term.
It would in many ways be nice to move in the opposite direction, towards using constructor arguments as much as possible so that more fields can be final
. This would help the compiler and the nullability analyser out. Stages are however all (by definition), identifiable components and that mandates a mutable id
field… so we can never fully avoid properties.
One counterexample to this is
GenerateIdStage
, which has a constructor providing a strategy bean, defaulting to an instance of a specific default strategy.This should be done with a property instead, the default value being applied during bean initialisation.