- 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
Admin
Admin
Admin
Admin
I love it. Take me behind the shed and bury me if I ever produce something like it.
Admin
WTF are you doing with that bit shift operator?
Admin
Who are you, Hitler?
Admin
Well to be pedantic, you only need one of them, as either of them can be constructed from the other, kind of like you only need one instruction to have a turing complete language ('subtract and branch if negative' as I recall). Not that using only NAND operations or 'subtract and branch if negative' is advisable for any real work... :-)
Yazeran.
Plan: To go to Mars one day with a hammer.
Admin
Too many values. You need to use a double between 0.0 and 1.0. 0.0 indicates absolutely false and 1.0 indicates absolutely true. .5 indicates "Maybe". Using a floating point number, you can express using various shades of certainty.
Admin
Simple Jedi Mind Trick These are not the droids you're looking for.
Complex Jedi Mind Trick Droids other than these are not the droids you're not looking for.
Admin
+1.333333333333333333333333
Admin
Alex you overcomplicated it yourself! All you need is NAND. AND, OR, and NOT are made using different combinations of NAND gates.
Admin
Storm trooper: "Maybe so, old man, but the droids other than these that are not the droids we're not looking for are also not the droids we're looking for. They're not on our list at all. These droids, however, are definitely the ones we're looking for, and we're taking you in."
(Good going, Obi-wan. There goes a bazillion dollar movie and toy franchise out the window.)
Admin
How do you know? All we get is the pre-compiled binaries - we have no idea what the source code looks like.
I believe we need to start an online petition to God to open source his code. Because online petitions work.
Admin
FTFY
Admin
Admin
Great, Akismet says linking to documentation is spam.
Admin
Push over VB, now there is something leaner!! Nice to know us VB programmers aren't the only ones who know how to write crap.
Admin
Admin
Yeah but is not is not not is.
Admin
In Java 5 there is auto boxing so this is perfectly valid
Admin
Boolean.FALSE is an object, so this is perfectly valid with or without autoboxing.
Admin
I bet the author of that line of code prefers to brush his teeth by going up through his ass; and is probably Romanian*
*a former coworker was Romanian and all of his logic was backwards like this example.
Admin
Admin
Wait, so C/++ booleans aren't universal? What happened to 2,3,4,5,6,...?
In reality, we know that compilers give at least a whole byte to booleans because of the difficulties and slowness of trying to pack multiple booleans into a single byte. So it you use less than 256 values in your booleans, you are wasting space with a suboptimal solution.
Admin
Admin
I like the floating 0-1 for a bool as well,
'Or' is the higher of two values, while 'And' is the lesser, 'Not' is 1-value...
Admin
No.
It only has 3 states.
Tri-state booleans have 4 states. (See: http://www.oracle.com/technology/products/jdev/esdk/api1013/oracle/ide/util/TriStateBoolean.html for details)
Admin
Is this security by absurdity?
Admin
Admin
Here is your enterprisey boolean:
And as an extra bonus, the schema:
Yes, it does validate.
Admin
Actually, it might not be. After refactoring some legacy VBA code in a DB front-end that caused it to crash in a different part of the code than when it normally crashes, I basically got banned from maintenance programming.
Now I only get to work on brand-spanking new .NET projects all by myself from start to finish. Boo hoo. >:D
Admin
Yoda Mind Trick Not looking for not these other droids you are.
Admin
The problem with this line of reasoning is that it is in the face of what software development methodology is supposedly about. Namely human factor -- the programmer, that is.
Let me elaborate: the only reason for "modern" programming methodology, now and then, was to make it easier for people to deal with the code. Oftentimes trading off instantaneous convenience and agility for longer term maintainability and ease of understanding by others. So it is hopefully understood that quite often one will code in a particular way not because it's expedient to him/her, but because it will take longer, and it's OK because others in the group will be able to manage better.
So in light of that, improving the quality of code is hardly counterproductive. It may not be productive if you just look at the person who is immediately dealing with the code, true. But it may be quite productive if you look at the big picture.
Think about it like so: if I were to whip up a single dynamically-generated webpage, with some demands placed on scalability and whatnot, I'd probably code the whole thing up in plain old C, without a webserver or anything else in sight, talking directly to whatever backend data source is to be used. I did enough embedded programming to know how to do that. It'd certainly be fastest for me. I would directly use whatever async networking APIs are provided by the OS, etc. All low level and sweet and fast, but a typical web developer would probably be rather stumped upon seeing something like that, and that doesn't mean he is in the wrong of course.
So I do appreciate that there will be other people who have to work on that code, thus I will leave the sometime expedient homemade coding for googling and reading up documentation for various higher level APIs, libraries and tools out there. So I may in fact be less productive in terms of lines of code (hey, I'll be reading for 80% of the time!), and may even develop a solution that is a few times slower than ultimately possible. But this can be well be still worth it if it lets others in the team deal with code that mostly builds on well documented concepts and solutions, and uses methods that are more familiar to those in the field. Even though web applications technically have to deal with asynchronous socket I/O and whatnot.
Admin
It's so damp in here the place is now covered in worse-than-failure mould*.
Admin
The real WTF is that this piece of code skips validation when it's not valid.
notValid = false != 0 ==> Don't skip validation notValid = false = true ==> don't skip validation notValid = false ==> don't skip validation notValid = true ==> skip validation
But then we are left with the next quite existential preponderance. How do we know if it's valid or not, if we skip validation?
Admin
Oh, god, what a boolean mess! I'm not a programming genius (I'm quite near to a codemonkey) but I've always looked for the simplest way to write a condition.
I suppose ... if the state is valid the Validation is done.
But it's quite tricky
Admin
I suspect... :-D
.. !=0 is useless and I think the overmentioned condition equals to:
doValidation = false; if (!statusIsNotValid) { doValidation = true; }
another (better) way
skipValidation=false; if (statusIsNotValid) { skipValidation = true; }
and THE BEST and simpler way (The only resonable way):
skipValidation = statusIsotValid;
the boolean skipValidation return value equals to statusIsNotValid.
Am I right?
Admin
ahh, the old converse vs contrapositive.
I am not an animal, I am a human. I am a man!
Admin
Mhh I'm pretty sure we could find quite a few more in some infamous languages like VFP (yes it's ugly so what) : .T. and .F. Anyone care to complete this boolean_of_doom ?
Admin
that piece of code is a big no-no
Admin
FTFY -- actually you just need nor, you can mimic nand with it.
Admin
I don't understand why everyone's complaining? This is a WTF yet Shakespeare wrote "To be or not to be" and he's hailed as a flippin genius.
Bah.
Admin
@FIA
I don't understand if our are joking... I don't think romance/tragedy's style is related to programming' style. IMHO I think that being concise and avoiding ambiguous statements is mandatory when programming /IMHO
Admin
I ran into some code just last weeek that used the "Anti-Boolean" type.
bool IsNotAuthenticated;
Reading conditional statements that use these make my head hurt.
Admin
For future ease of reference, shouldn't the nomenclature be standardized?
Three-state boolean = troolean Four-state = foolean Five-state = quoolean [pronounced cool-lee-ann]
States greater than five could be grouped either as droolean or eff-yoolean.
Admin
Bravo, a completely pointless expression, that's the way we like them !
Admin
I reached the opposite conclusion.
Original:
Simplifying one thing at a time, and assuming !=0 means false:
So if the status is not valid, then validate. Really, whether I'm right and you're wrong, you're right and I'm wrong, or somehow both of us are wrong, the real WTF is just what it claimed to be: the code is way too hard to understand.
Admin
I'd simplify it differently. The contract of compareTo/equals is that a.compareTo(b) == 0 iff a.equals(b), so
That last one is even readable.
Right. I wonder whether it was deliberate obfuscation.