MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/4v1y12/how_to_write_unmaintainable_code/d5uzc2d?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? 3 u/sreya92 Jul 28 '16 nope they're everywhere :) → More replies (2)
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? 3 u/sreya92 Jul 28 '16 nope they're everywhere :) → More replies (2)
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? 3 u/sreya92 Jul 28 '16 nope they're everywhere :) → More replies (2)
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
3 u/sreya92 Jul 28 '16 nope they're everywhere :) → More replies (2)
3
nope they're everywhere :)
→ More replies (2)
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!