sharpbrick/powered-up

Simplify parameter typing

Closed this issue · 2 comments

This is horrible UX:

await motor.StartPowerAsync((sbyte)(CW * MaxPower));

The variables CW and MaxPower are both sbyte but the language converts them in an int during the multiplication (not if done using literals ;(). StartPower only accepts sbyte.

Consider either overloading with int or generally changing to int as input for methods. The performance is not impacted by that (int is generally recommended) and guarding anyway need to be applied in each method (since most calls are 100 bound)

While playing with the idea of removing CW and CCW entirely (they have a problem anyway with orientation of the motor (do I look at it or am I behind it), there is another factor: Binding it to UI or other code. More troubles than benefits. Overloads it is.

Overload resolution turned out to complicate things. If the first parameter was selected in the beginning, the lazy (int) variant later would be in conflict with the first parameter.

Decided to drop this issue.