- 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
For bonus points:
Will return the value of Test if it is not null, otherwise it will return the value of IfNull.If the If is not the part of an evaluation or assignment the code is invalid and will not compile. IIf does not need to be a part of an evaluation or assignment. See also: http://ideone.com/e81FvE
Admin
I would give you "like", but there is not this kind of button :-).
Admin
mentor == false
dementor == true
Admin
Then again, the original commenter thinks everyone except morons should be manipulating boolean values with bitwise operators, so that kinda calls into question the frame of reference we're dealing with when confronted with words like "moron" and "messed up".
Admin
Flashback...
Some non software guy (probably management): "See, its easy, in this text editor you can change all the A's to B's". He says after saving the file, overwriting the only copy.
Question from a real software guy: "How do I change it back to the way it used to be, as it was my only copy?"
Non software guy: "Oh, that's easy, just change all the B's to A's. Let me show you!"
Real software guy: "Arrrg" as he does a faceplant.
Admin
Actually, my current post is almost exclusively filled with such 'seniors' - people with 10, 15 and even 20 years of service with the same company.
Not actually very good when they started. Not learned much over the years. Never challenged by equally inept management to improve and never seen the need to improve.
Plus, they're often antagonistic to any attempt to improve.
The sad thing is if the company hits a problem and they are made redundant, they are utterly unemployable by anyone not on medication.
Look up the articles on the Deadsea Effect and you'll see it's not uncommon to see this.
Admin
Admin
Admin
I think I'll use that as my job description.
Admin
Admin
Admin
Maybe the senior developer is a VHDL or Verilog developer at heart?
In both languages, the code would have behaved as intended, provided the non-blocking assignment operator (<=) was used!
Admin
Once I told my non-programmer friend that "forum password != FTP password". He spent the next 20 minutes trying to use the FTP with the forum password.
Admin
Even if he'd included the ELSE clause so the function gave correct results, it's just dumb.
I know there's lots of bad code out there, but for some reason one thing that annoys me every time is:
What is the purpose of the test? So if flag is already false, we don't unnecessarily set it to false?
A very similar one I see all the time is:
Because if we omitted the test and added zero to the total, that would totally screw up our results.
My only guess is that programmers who write this think they are making the program more efficient. If the amount is zero, we can save the effort of performing an addition that won't change the total.
Except ... umm ... Think about this logically for a moment. If the amount is not zero, then you're stilling doing the addition, plus you're doing the test. So clearly it must take longer in the case where the amount is not zero. If the amount is zero, then on any computer where I've ever actually checked into it, the test takes longer than an addition. So you're "saving" the time to do a faster function by instead doing a slower function. So in both cases, you lose.
Admin
The point of doing if(flag==true)flag=false; Is to toggle something from on to off. It increases readability of the code. The test for true is superfluous though.
Admin
Admin
Admin
Wha..?
You can see that's not the intent of the code though right? That's what it does but it's clear to see that the intended purpose was to flip the boolean.
Admin
While C tricks are fun, wouldn't this be easier to read: (a==NULL) != (b==NULL)
Admin
Admin
100% valid:
Admin
Dmitry Karasik has an interesting list of esoteric Perl operators:
http://www.nntp.perl.org/group/perl.fwp/2007/11/msg4028.html
Yes - a list of operators that Perl developers consider esoteric.
Admin
Admin
Uh, in python you can also use:
Admin
Your comment is magnificent!
Even the CAPTCHA agrees: ingenium.
Admin
Admin
Oh, didn't realise we were talking ternary operators. I am an idiot. Please continue.
Admin
Admin
If you want to see what happens when a Python programmer gets Perl envy, take a look at Ruby. The worst of both worlds...
Admin
Admin
The problem isn't the truth table. It's the fact that he thinks he's pattern matching. That is, he thinks that there is an implicit case around the two if-blocks, and that only one of the if-blocks will get run.
The guy even said as much.
Admin
That's less.
Admin
No way can a senior developer write that code. OK, maybe he can write that code, if he was having a horrible day, but no way would he not spot the problem once it was pointed out to him. No matter how incompetent.
I can't believe this one.
Admin
That's why the first rule of optimization is, "Don't do it."
Admin
And another rule is, "don't try to be smarter than the compiler."
Admin
Because... That that is is that that is not is not
Admin
Admin
"You could just do, showOptionsButton = (showOptionsButton) ? false : true."
"Ewwwww!" Jim said. "Question marks belong in grammar books, not code."
Admin
Some libraries I work with seem to prefer the following syntax:
showOptionsButton ^= true;
Not sure if that works in C#, or Java, or whatever language they're trying to use, but it works fine in C++ :)
Admin
My coworker and I cannot figure out what this comment means. Is it a sarcastic joke or an actual better way? Can you expound on the example so we can be brought into the loop on this one?
Is it like this?
value =!!=!=!value;
Admin
Admin
Admin
TRWTF is Ben's inability to explain why this doesn't work. As a previous commenter already pointed out: a simple flowchart would suffice.
Admin
True....
Admin
True....
Admin
True....
Admin
True....
Admin
Admin
I'm hoping not to fall for some double irony here: It says that the =! operator(s) are not the same (therefore the middle !=) as the != operator and this is furthermore emphasized using the ! at the end.
Btw: Did you know of the "converges to" operator in C/C++:
Admin