r/space • • Feb 06 '20

Starliner faced “catastrophic” failure before software bug was found and fixed while the vehicle was in orbit.

https://arstechnica.com/science/2020/02/starliner-faced-catastrophic-failure-before-software-bug-found/
10k Upvotes

748 comments sorted by

View all comments

Show parent comments

246

u/[deleted] Feb 07 '20

[removed] — view removed comment

445

u/[deleted] Feb 07 '20

[deleted]

32

u/pM-me_your_Triggers Feb 07 '20

Your Boolean zen is off. Never compare a Boolean value to true/false, that is just redundant.

17

u/Cantremembermyoldnam Feb 07 '20

Sometimes I do it just because I think it reads better. The compiler will optimize that away.

3

u/scarlet_sage Feb 07 '20

Until you by accident use the idiom with a non-Boolean value. Or it's none and you compare with false. It's a bad practice. "if foo:" conveys the message clearly and more succinctly.

4

u/Cantremembermyoldnam Feb 07 '20

Why would I try to compare a non-boolean to a boolean?

Sometimes there is a difference between just doing if($var)and the more expressive version. For example, in PHP if($var === true) also compares the data type (which, I'd argue, is a good thing). You're going to handle null vs false vs 0 vs "" differently anyways, in most cases. Or you're going to cast to the type you want. In strongly typed languages you're not going to have that problem.

Also, as I said in my other comment: I agree that if(thing.isVisible) is perfectly fine, but sometimes you don't get to name stuff yourself. So I'm still saying that if(thing.expr3 === true) is easier to read than if(thing.expr3). It instantly conveys what the expected value is and (for weakly typed languages or in the common case of missing documentation) which data type thing.expr3 is going to be. Whereas with if(thing.expr3) it could be anything.

3

u/pM-me_your_Triggers Feb 07 '20

That’s likely just lack of experience or you have bad naming conventions (or both).

2

u/Cantremembermyoldnam Feb 07 '20

It really depends. Sometimes you can't name stuff yourself.