- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
What should true and false be, if we want to be compliant with standard exit codes?
In bash, try:
Admin
FTFTFY: This Yoda's head explode would make.
Admin
My favorite bool WTF was the guy who made a java program with two static AtomicBooleans, FileReader.TRUE and FileReader.FALSE. Everywhere throughout the code, he would do a reference comparison between a given bool and either FileReader.TRUE and FileReader.FALSE.
The general idea was that there would be multiple kinds of readers, but this guy only implemented the FileReader, then passed it on to me for the rest. So I did some quick refactoring and quickly found that things were failing because SQLReader.TRUE != FileReader.TRUE
I went and asked the guy WTF he was doing and had the most awkward "you're not getting it" conversation ever when he kept trying to tell me that he did it that way because "it has to be atomic".
Admin
lol I like the hidden Cornify :) (click on "truth truly is ," on one of the last paragraphs... you won't be disappointed)
Admin
That's not enough to resolve all the possible states...
There's also weak pull up/down, strong pull up/down as well. As well as open-collector/open-drain.
Otherwise you can't simulate some logic, like say, USB.
(USB uses weak pullups on the host - the stronger pulldowns on the device give determination between USB slow speed and USB full speed. High speed is negotiated through some special signalling during enumeration (chirps), and super speed well, probably uses the other pins.
But having logic tied together means the logic has to take into account any pullups and pulldowns to resolve. (And yes, "driven" will override any pullup/pulldown, and a strong pull up/down will override a weak pull down/up, respectively).
Admin
Admin
Invoice for new keyboard in the post!
Captcha: Paratus, Even almighty!
Admin
Admin
if (x == false) {x = true};
This can actually save cycles and bandwidth: Say you have x in your desktop box but setting x is logged at the server. Fhen, if you set x, you'll have to wait until the server logs "User set x to true" and tells your box that it did. Checking if x isn't already true takes place in your box, which takes only nanoseconds or less. Setting x to true adds network traffic and a wait which is usually some microseconds, if not milliseconds. Depending on your environment, it may be better to avoid as many logged actions as possible. /* If you have to check for performance reasons, it always deserves a comment - / / or some other coder will rewrite it and bottleneck the LAN eventually */
if (a) foo(a); else foo(a);
I must confess that I wrote that code twice. Once, it survived for weeks, the other one more like ten minutes. (Decent compilers detect that kind of waste and compile foo(a); anyway) The old code used to be
if (a) foo_nonzero(a); else foozero(a);
Both times, the old foo_nonzero() had been improved to handle zero, thus eliminating the need for foo_zero. So, I'd say that an if (a) foo(a); else foo(a); is not a WTF. It's an artifact of old code. Unless it's in new code. Then it IS a WTF.
About x.isTrue() and all the "boolean" silliness, some of them are less silly if they imply a type cast to boolean. However, type-casting is a WTF waiting to happen /* if it's not documented */
Capcha: causa. As in, "I code in VB, causa fucked up manager duzn't allow any real language"