- 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
frist = !frist
or maybe, frist!
Admin
if (!fristJokeStillFunny) then fristJokeStillFunny = true; if (fristJokeStillFunny) then fristJokeStillFunny = false;
Admin
what do we learn from this? no matter how long you do something it does not mean that you are good at it.
Admin
If (firstpost == frist) deleteFirstPost();
If (secondpost == frist) callSecondPosterIdiot();
//See what I did there?
Admin
Booleans are hard, man. The previous statement is maybe !not entirely completely unfalse.
Admin
=! != != !
Admin
And why didn't Ben suggest that they try this out? Making a wager would have been a good idea, too.
Admin
PS - Nomination for featured comment (I presume Alex scrapes for the word featured comment - can't think of many other reasons to stay with this software)
nulla - There's another reason..
Admin
makes no sense to talk to such guys, just check from time to time what they checkin and then have some funny stuff to read and share
Admin
Or, if your language does not convert non-zero integers to true:
Or, if the other people on your team are morons:
If you want to be explicit:
If you want to be explicit and others are not smart enough to understand the ternary conditional operator (or your language does not have/messed up the TCO):
If you are paid by the character/SLOC:
Don't forget documentation and unit tests, though.
Admin
I've seen some pretty poor new developers, but I can't believe anyone could stay working for a company and not understand how an If statement works, let alone get to be a senior developer. Surely this can't be genuine
Admin
As he is refered to as "senior", perhaps, he has just forgotten.
Admin
You can't fix stupid....
Admin
Reminds me of a mistake I had to debug once. There was a configuration file, which contained some clauses of the form <attributename>=<regex> or <attributename>!=<regex>. Since ! was not a valid character in the attributename, this syntax was unambiguous. But accidentally someone had messed up in one configuration file and written <attributename>=!<regex>. Turns out this would also be parsed as valid, since ! is a valid character in a regex.
Admin
Admin
Admin
This is one of those times where drawing a flowchart really helps.
Admin
Some time ago we had here an article about a guy who had problem understanding the try-catch-finally construct, now we've got this one having problem with the if-else. What next? A moron who can't write an assignment? Oops, I'm sorry: here we've got that too, so this is a double WTF!
Admin
PHP springs to mind, with this nugget:
(Taken from http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/)Admin
Jim,
When you get a moment, could you look at a couple unit tests I've written? They don't seem to be giving me the expected results.
Source:
#include <iostream>
using namespace std;
bool test_one(bool showOptionsButton) { if (showOptionsButton == true) showOptionsButton = false; if (showOptionsButton == false) showOptionsButton = true; return showOptionsButton; }
bool test_two(bool showOptionsButton) { showOptionsButton = !showOptionsButton; return showOptionsButton; }
int main() { cout << "test_one(false) returns " << test_one(false) << endl; cout << "test_one(true) returns " << test_one(true) << endl; cout << "test_two(false) returns " << test_two(false) << endl; cout << "test_two(true) returns " << test_two(true) << endl; return 0; }
Output:
test_one(false) returns 1 test_one(true) returns 1 test_two(false) returns 1 test_two(true) returns 0
http://ideone.com/du77Rl
-- Ben
Admin
You don't need to explain anything.
Just each write out truth tables, then compare them. If Jim is still unable to get it, write out step-by-step truth tables.
If he's still unable to get it, either resign, or get Jim fired.
Admin
when doing parameter validation in C I often needed to check whether one or the other or both string parameters was not null. this led to lots of expressions like
if (!!a != !!b) { ReturnError("you must either specify both a and b or omit them both); }
Admin
In Python, it's a little messed up:
Admin
Bool OldValue = Value; while(Value == OldValue) { switch(rand() % 3) { case 0: Value = True; case 1: Value = False; case 2: Value = FileNotFound; }
Admin
Admin
So this could be replaced by
if (showOptionsButton == false) showOptionsButton = true;
It cannot be replaced by simply
showOptionsButton = true;
because that would change the result when showOptionsButton == FILE_NOT_FOUND;
Admin
"Some people have 10 years of experience. Others have 1 year of experience 10 times."
(source unknown)
Admin
I'll be honest, I've done this once because I had other things on my mind. But not with an if statement quite so trivial. Still, at a glance you can make such a mistake.
Admin
The Schrödinger's cat indicator. If you look at the value of a boolean, the state changes.
Admin
TRUE factorial?
Admin
Jim must be one of those "1 year of experience 12 times" type senior developers.
Admin
wow, just wow.
You sir, are a true master of building a codebase only you can work ok.
Personally, I might want to let someone else do maintainance on stuff I wrote, so I'd let them have a clue what it does.
if ((a==null) != (b==null)) {}
yes, could have used an xor, but that's not as readable.
Admin
Admin
It was added as an operator in 2008.
s.ToString will never be evaluated. Replacing the line with
will throw a Null Reference exception.Admin
Totally believe this, I've seen such work from a "senior" software engineer before. It wasn't malice, just caring about getting something done fast and not paying attention to it, because as long as you tell the boss it's done who cares if you have to fix it later? The feature was implemented.. nobody said it had to be implemented CORRECTLY.
Admin
Is this some secret code for frist?
Admin
Admin
Clearly Jim was considering the case where showOptionsButton == FileNotFound.
Admin
You'd be surprised. Some time ago when I joined a company as a FORTRAN developer (yes, a long time ago) I was assigned a mentor who, soon after I had settled in my seat, asked me how to write a DO loop. Not that she was testing me to check that I had the appropriate knowledge, but because she genuinely didn't know how do it. She'd had a piece of code bounced back 3 times from her boss and still hadn't managed to do what it needed to do.
In the words of King Crimson: "Please teach me." Mmm. I taught her.
I later asked around to find out how she had got to be a mentor. "By begging," I was informed.
Admin
The ! belongs to the side which isn't equal.
Admin
I don't know in what way I would have reacted to this. Violence seems adecuate.
Admin
I love this quote from the PEP which defines the conditional expression:
Basically, BDFL said: "fuck it, let's implement it like this".
It's also funny that if you google for BDFL, a picture of van Rossum is shown.
Admin
!first
Admin
"No, it won't" Yes it will you idiot. What kinda stupid man makes you the mentor? And to make it even worse, you didn't do the BEST option in the first place! Nothings easier than x = !x;
Admin
My second day, on my very first programming job, working in C with an ISAM database library, I was reading through the code, and went to the lead, who was supposed to be breaking me in, with a question.
Q: Why are we always searching through the database records sequentially? Surely the database library provides some sort of mechanism for searching for a record using an index.
A: I don't think it does.
Of course, it didn't take me long to find the feature in the ISAM library's documentation.
Two months later, he got a bonus for the significant speed improvements he'd made in the application.
Admin
My thoughts exactly!!
Admin
That that that that boy wrote is not that that that that boy wrote.
Admin
Admin
"... I’d love to explain the basics to you, but I really need to get this feature finished."
And so I finished the new feature :
Switch(showOptionsButton){ case (true): showOptionsButton = false; case (false): showOptionsButton = true; default: showOptionsButton = if(rand()%2); }
Admin
real wtf is people not noticing it is simply