3 ms·
A former primary developer of my code base had something wired backwards in his brain. The code is full of double negatives: if(!FeatureNotDisabled){ ....
by vidanay 8y ago
A former primary developer of my code base had something wired backwards in his brain. The code is full of double negatives:
if(!FeatureNotDisabled){
....
}
It drives me absolutely bonkers!
- rabidrat 8y agoFor me this often happens incrementally. Like they started with "if (FeatureNotDisabled)" and then locally refactored the code until it was "if (!FeatureNotDisabled)". The problem is that they then didn't go back for another pass before commit, and reverse the double-negative by changing the variable name and semantics. This could be due to laziness, ignorance (it works, what's the problem?), fear (it works now, let's not break it), or time mismanagement (it took long enough to get it working, no time to make everything "perfect").
- vidanay 8y agoI could understand that evolution, but I have become convinced that this particular developer simply worked with negative logic in his brain. Even the configuration files will have: Feature1Disabled=False Feature2Disabled=True Feature3Disabled=False Instead of using feature flags to enable a feature, he used feature flags to disable features. He was very consistent and the logic is all correct, simply inverted.
- timw4mail 8y agoThat's a triple negative! (!, Not, Disabled). Yes, `if (!FeatureEnabled){ ... }` would be clearer.
- dragonwriter 8y ago> That's a triple negative! (!, Not, Disabled). It's only a double negative (“disabled” is affirmative, though the same sense can be communicated by the single negative “not enabled”.)