NumberSignal does not have decrementBy API
Describe your motivation
NumberSignal has incrementBy API, which is very convenient in most cases. It would be nice to have decrementBy API, as well.
Describe the solution you'd like
Introduce decrementBy(double delta) that decreases the value by the delta amount
Describe alternatives you've considered
I used the increment API with negative numbers.
Additional context
Additionally, some utility method would be nice e.g. incrementByOne(), decrementByOne()
Why isn't incrementBy(-1) sufficient?
Debugging gets easier as you know which methods to track when looking for why the number is decreased.
It would make api symmetrical. It is the first method that you think of when you need to decrease a number.
It goes both ways. As long as incrementBy also accepts negative values, you would then have to look for invocations of either incrementBy or decrementBy to find the right place. (And I don't thinks we should make incrementBy reject negative values since that forces a completely pointless if (delta >= 0) incementBy(delta) else decrementBy(-delta) construct on cases that need to support both).
I would guess the main problem is discoverability, but it does so far seem that users do find the incrementBy(negativeValue) option relatively easily.
I am not saying that incrementBy should reject negative values, but rather there should be a decrementBy API that can even call the incrementBy method with a negated delta value.
I would guess the main problem is discoverability, but it does so far seem that users do find the incrementBy(negativeValue) option relatively easily.
Except me 😆 I even opened the NumberSignal class and looked for a method that does a subtraction operation