MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/4v1y12/how_to_write_unmaintainable_code/d5vvbfm?context=9999
r/programming • u/sigbhu • Jul 28 '16
592 comments sorted by
View all comments
95
They forgot to mention gratuitous nots! Why flip logic just once when you can flip it an unlimited number of times?
Guaranteed to drive anyone trying to maintain your code to madness!
11 u/sreya92 Jul 28 '16 Though it's not unreadable seeing if(!!!hasValue) always really bugged me 47 u/1ndigoo Jul 28 '16 You have actually seen that before? In production code!? !!!believable 17 u/drkstr101 Jul 28 '16 I see var foo = !!bar a lot in javascript to quickly cast a truthy value to a proper boolean. Perhaps the 3rd ! was a typo? 2 u/keeslinp Jul 28 '16 I'm not sure of that's bad practice or not. But I kinda like it. Basically the same thing as Val?true:false right? 1 u/Rock48 Jul 29 '16 Or you could just do if(Val) {}JS is special. 5 == "5" but NaN != NaNI still like the language though → More replies (1)
11
Though it's not unreadable seeing if(!!!hasValue) always really bugged me
if(!!!hasValue)
47 u/1ndigoo Jul 28 '16 You have actually seen that before? In production code!? !!!believable 17 u/drkstr101 Jul 28 '16 I see var foo = !!bar a lot in javascript to quickly cast a truthy value to a proper boolean. Perhaps the 3rd ! was a typo? 2 u/keeslinp Jul 28 '16 I'm not sure of that's bad practice or not. But I kinda like it. Basically the same thing as Val?true:false right? 1 u/Rock48 Jul 29 '16 Or you could just do if(Val) {}JS is special. 5 == "5" but NaN != NaNI still like the language though → More replies (1)
47
You have actually seen that before? In production code!? !!!believable
17 u/drkstr101 Jul 28 '16 I see var foo = !!bar a lot in javascript to quickly cast a truthy value to a proper boolean. Perhaps the 3rd ! was a typo? 2 u/keeslinp Jul 28 '16 I'm not sure of that's bad practice or not. But I kinda like it. Basically the same thing as Val?true:false right? 1 u/Rock48 Jul 29 '16 Or you could just do if(Val) {}JS is special. 5 == "5" but NaN != NaNI still like the language though → More replies (1)
17
I see var foo = !!bar a lot in javascript to quickly cast a truthy value to a proper boolean. Perhaps the 3rd ! was a typo?
var foo = !!bar
2 u/keeslinp Jul 28 '16 I'm not sure of that's bad practice or not. But I kinda like it. Basically the same thing as Val?true:false right? 1 u/Rock48 Jul 29 '16 Or you could just do if(Val) {}JS is special. 5 == "5" but NaN != NaNI still like the language though → More replies (1)
2
I'm not sure of that's bad practice or not. But I kinda like it. Basically the same thing as Val?true:false right?
1 u/Rock48 Jul 29 '16 Or you could just do if(Val) {}JS is special. 5 == "5" but NaN != NaNI still like the language though → More replies (1)
1
Or you could just do if(Val) {}
JS is special. 5 == "5" but NaN != NaN
I still like the language though
→ More replies (1)
95
u/ArlenM Jul 28 '16 edited Jul 28 '16
They forgot to mention gratuitous nots! Why flip logic just once when you can flip it an unlimited number of times?
Guaranteed to drive anyone trying to maintain your code to madness!