sharpbrick / powered-up

.NET implementation of the LEGO PoweredUp Protocol
MIT License
100 stars 19 forks source link

Simplify parameter typing #73

Closed tthiery closed 4 years ago

tthiery commented 4 years ago

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)

tthiery commented 4 years ago

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.

tthiery commented 4 years ago

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.