Pre-submission Checklist
Description
Several types have constructors with many parameters, several of which are Option<T> with None as the overwhelmingly common value. This forces callers to spell out positional None arguments whose meaning is opaque at the call site and makes it easy to pass arguments in the wrong order.
Three prominent exampels are SGPPropagator::from_omm_elements (18 parameters, 9 optional), WalkerConstellationGenerator::new (12 parameters, several almost always zero) and DNumericalOrbitPropagator::new (8 parameters, 4 optional)
Use Case
// Current — caller must know the position and meaning of every None
let prop = DNumericalOrbitPropagator::new(
epoch,
state,
NumericalPropagationConfig::default(),
ForceModelConfig::leo_default(),
None, // params
None, // additional_dynamics
None, // control_input
None, // initial_covariance
)?;
Proposed Solution
Introduce a builder for each affected type. Required fields are passed to builder(); optional fields are set by name and default to None or a sensible value if omitted.
let prop = DNumericalOrbitPropagator::builder(epoch, state, ForceModelConfig::leo_default())
.propagation_config(NumericalPropagationConfig::high_fidelity())
.initial_covariance(p0)
.build()?;
The codebase already uses this pattern in several places (events, trajectories, Jacobian config), so the convention is established.
Impact on Existing API
No impact (new functionality only)
Impact Details
None. Existing constructors remain unchanged; the builder is additive. The clippy::too_many_arguments suppressions on the current constructors can be removed once call sites are migrated.
Contribution
Pre-submission Checklist
Description
Several types have constructors with many parameters, several of which are
Option<T>withNoneas the overwhelmingly common value. This forces callers to spell out positionalNonearguments whose meaning is opaque at the call site and makes it easy to pass arguments in the wrong order.Three prominent exampels are
SGPPropagator::from_omm_elements(18 parameters, 9 optional),WalkerConstellationGenerator::new(12 parameters, several almost always zero) andDNumericalOrbitPropagator::new(8 parameters, 4 optional)Use Case
Proposed Solution
Introduce a builder for each affected type. Required fields are passed to
builder(); optional fields are set by name and default toNoneor a sensible value if omitted.The codebase already uses this pattern in several places (events, trajectories, Jacobian config), so the convention is established.
Impact on Existing API
No impact (new functionality only)
Impact Details
None. Existing constructors remain unchanged; the builder is additive. The clippy::too_many_arguments suppressions on the current constructors can be removed once call sites are migrated.
Contribution