Share our boolean flag war stories!

Have you been caught-out by boolean flags before?

Of course you will have never used them yourself, but perhaps you’ve had to work with somebody else’s code?

Anyway, share your war stories here!

1 Like

Yeah, I have been fighting with a similar issue, funnily because of this lecture :smiley:

Using the CurrentThrottle as a member variable somewhat created the same problem as using a boolean flag for me.
I set the value for the CurrentThrottle in the SetThrottle() Method, but when calling the DriveTrack() Method I couldn’t be sure that the CurrentThrottle still has the same value as when I set it. In fact, through debugging I found out, that the value has change in between setting it and calling it, because another event was using the SetThrottle() function as well (which was still the event from the conventional, non-FlyByWire Control architecture, which I left in for fun).

Though, this only becomes a problem when the CurrentThrottle is directly assigned the Throttle / Throw. As soon as you set the CurrentThrottle = CurrentThrottle + Throttle it doesn’t matter when an event calls this method and passing a zero in.

Still, I find it interesting, that we are trying to avoid boolean flags, because we can’t be sure that this state still exist at the time we are asking for it, vs. for the time we set it, but for me a similar issue is for setting a member variable at one time, but retrieving it at another time, we can’t be sure it is the same :smiley:

Privacy & Terms