Skip to main content
integrate proposals for Option and Result
Source Link
Thibe
  • 401
  • 3

The only arguable objection I have is the missing possibility to detect configuration errors from the calling code.

If it is intended to detect errors only by reading the output and implicitly fall back to a default or last sucessfully set value, then this approach is fine.
If there is a need to react to configuration errors individually (e.g. print "No, you won't get a car from me") then I see two possible solutions:

  1. Use configuration functions that report whether the call succeeded or not, e.g. Option<Vehicle> or Result. Unfortunately that would make the configuration less convenient than the functions which return self as you loose the possibility to directly chain the commands.
  2. Set a testable error flag or Result in the builder, optionally have one error flag or Result for each build step to be able to locate or resolve the error.

The only arguable objection I have is the missing possibility to detect configuration errors from the calling code.

If it is intended to detect errors only by reading the output and implicitly fall back to a default or last sucessfully set value, then this approach is fine.
If there is a need to react to configuration errors individually (e.g. print "No, you won't get a car from me") then I see two possible solutions:

  1. Use configuration functions that report whether the call succeeded or not. Unfortunately that would make the configuration less convenient than the functions which return self.
  2. Set a testable error flag in the builder, optionally have one error flag for each build step to be able to locate or resolve the error.

The only arguable objection I have is the missing possibility to detect configuration errors from the calling code.

If it is intended to detect errors only by reading the output and implicitly fall back to a default or last sucessfully set value, then this approach is fine.
If there is a need to react to configuration errors individually (e.g. print "No, you won't get a car from me") then I see two possible solutions:

  1. Use configuration functions that report whether the call succeeded or not, e.g. Option<Vehicle> or Result. Unfortunately that would make the configuration less convenient than the functions which return self as you loose the possibility to directly chain the commands.
  2. Set a testable error flag or Result in the builder, optionally have one error flag or Result for each build step to be able to locate or resolve the error.
Source Link
Thibe
  • 401
  • 3

The only arguable objection I have is the missing possibility to detect configuration errors from the calling code.

If it is intended to detect errors only by reading the output and implicitly fall back to a default or last sucessfully set value, then this approach is fine.
If there is a need to react to configuration errors individually (e.g. print "No, you won't get a car from me") then I see two possible solutions:

  1. Use configuration functions that report whether the call succeeded or not. Unfortunately that would make the configuration less convenient than the functions which return self.
  2. Set a testable error flag in the builder, optionally have one error flag for each build step to be able to locate or resolve the error.