- 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
True. However:
I'll still contend (in general) if you have an
if
statement that looks like a George R R Martin description of a banquet scene; it's can be easier to understand at a glance if it looked something like:Admin
Hey guys... TRWTF? I think I found it.
Admin
https://www.youtube.com/watch?v=YuJEeAVWG4o This is the band that should have represented us at Eurovision. Sebastian schmebastian.
Admin
Comments are good (and should not be any more likely to be wrong than a descriptive variable name).
And if you happen to need to set a breakpoint on
if(... complicated expression ...)
, you can evaluate... complicated expression ...
easily enough with a simple copy-and-paste.Admin
Happier? (please excuse any baby-induced-sleep-deprivation that may have impaired my English this morning; it was a rough night)
Admin
Admin
Oh yeah, I know... it's fine as a speech idiom, it was just very evil when slipped into a sentence to demonstrate how bad double negative boolean operations in code are.
Admin
<blah blah blah iknowitsnotreallyfunny
Admin
:+1:
Admin
My hypothesis, which I haven't seen anyone else mention, is that the programmer was told at some point that an
if(...)
can only contain a boolean, unlike languages like C, where you can use an integer, or PHP, Python, etc., where you can use pretty much any variable type. The programmer, not knowing any better, thought that this meant that it can only have a single boolean variable.That sounds like a pretty typical :wtf:-generating programmer.
Admin
After reading the whole post, there is a big question mark left:
Is "cow-orker" a mistake or an intended typo?
Admin
Great, now that the elephant in the room has been pointed out....
Admin
Intended :wink:
Admin
I thought they were gonna use a bitfield in a boolean field. like:
Admin
http://www.catb.org/jargon/html/C/cow-orker.html
Admin
I didn't make it past the first error message:
All your base are belong to us.
Admin
Such as? (not snark: I'm genuinely curious.)
Admin
Bitfields and decimal representation? Naughty programmer spank spank spank.
Admin
Admin
Surprised nobody's picked up on this appalling instance of inverse logic:
Er, so count is not having sent the message, and if not count then add address to list of success message. And then it gets worse.
Admin
Admin
According to British naming conventions the variable should have be named earl.
Admin
No, "Earl" is a US first name. Earl ("Eorl") is actually Anglo-Saxon and predates the Norman aristocracy that set up our present system. But in any case British people aren't given names like Earl, Prince and so on because these are titles, i.e. reserved words. It would be like naming someone "Mister" or "Sir". In the US they are not titles and so can be used as personal names (i.e. variable names.)
Admin
You deserve the pedantic badge for that. Great explanation, though :)
Admin
I'm really surprised that on one commented on the author's, apparent, complete lack of understanding of how to properly use a "while" statement:
Really? There are potential reasons why you would want to manually loop though an enumeration, but I can't think of a single reason why you would intentionally setup this potential infinite loop (not in this context). Just wait for the day that something goes wrong, and that condition never lets the "break" happen. That'll be a not fun day for somebody.
Admin
I have. But we are in the second decade now, and anything before C11 is not C anymore. Oh wait, <stdbool.h> was part of C99 already. Are you using compilers that live more than 16 years in the past?
Admin
MSVC versions before 2013 didn't support C99 at all. MSVC 2013 only has partial support, but that does include
_Bool
andbool
(which expands to_Bool
).Admin
Just having the tests inline makes it a hell of a lot more readable anyway. If I'm around that point in the code, I want to know what is happening and I don't want it hidden behind layers (and sometimes layers) of other files.
Admin
Maybe. If this were Java I'd say the biggest :wtf: is the lack of the
final
keyword in the declaration of the mis-namedcount
variable, which would have stopped this code from compiling at all. But I don't know enough about .Net to know ifreadonly
can be used the same way asfinal
for local variables.Admin
I think it does; never tried it though
Admin
boolean count1, count2, count3, count4, count5, ah_ah_ah;
Filed under: Stealing the joke in the article
Admin
Good to know but I'll have forgotten by the next time it will be useful to me. :smile:
You're bad people. Immutability is awesome and eliminates or reduces entire classes of bugs. I have Eclipse set to add the final keyword when I save to all variables that aren't written again, which makes the variables written multiple times stand out for me to fix.
Admin
To be fair, it's very rare I have a variable I could make readonly
Admin
How does that happen? In my experience the vast majority of variables are written only once. Does your code need more decomposition or something maybe?
Admin
The stuff I work on often requires a fair amount of calculation. And I do tend to inline a fair amount too. Nothing too silly, otherwise it'd be an unmaintainable mess :smile:
Admin
final int partOneCalculation = calculatePartOne(); final int partTwoCalculation = calculatePartTwo(); fina int finalCalculation = calculateFinal(partOneCalculation, partTwoCalculation);
Admin
I see the merit in the approach; whether I use it or not though… no idea. I'll keep it in mind though.
Admin
To bastardize a quote for my own purposes: "I am not able rightly to apprehend the kind of confusion of ideas that could provoke such code."
boolean count1, count2, count3, count4, count5, ah_ah_ah, FILE_NOT_FOUND;
Am I doing it right?Admin
I was waiting for this. First reference to 'filenotfound'!!
Admin
How would the lack of final stop that code from compiling?
Admin
Lack of
final
doesn't stop it compiling, liberal use offinal
stops it compiling. Liberal use offinal
makescount
withoutfinal
obvious, drawing attention, hopefully the right kind, and an opportunity for improvement.Admin
Pah. Tricked me with your upside-down Aussie logic. Do your for loops go around the other way too?
Admin
I rejoice in my pendantry. When you get to my age, that and telling people to remove themselves from my lawn is about all you have left.
Admin
Basically what Erlang does - immutables.
Admin
:wtf:
Yes, I'm using C compilers with partial C99 implementation without
bool
which are not likely to change even in the next 16 years.Admin
Admin
Admin
For a true bool type b=1000 should give an error and not revert to one.
And in python: True + 5 => 6
Admin
Admin
I totally agree... they should have fixed that in python 3000. It is really terrible.