- 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
This was obviously written by someone unfamiliar with the "ToLower()" class. What is returned if I supply it with "trUe"?
Admin
Deep frown deepens...
Admin
How do you start on a contact? And how many weeks are a copule weeks? Sorry, I'm not a native English speaker, so I might not know certain idioms or words.
Admin
Oh! And fr1st! And and and what if you use oFf? That won't do! Who's the incompetent git that forgot oFf in that list? No end-year bonus for him!
Admin
And obviously... this StringSettingBool being a class, nobody got the bright idea to something like a toLower in both the constructor and in the instance method that checks whether the passed string is true or false (or file not found).
Admin
Ah! stolen thunder in the fr1st p0st.
I was going to add that they forgot nO, yEs, yeS, yES, YeS, YEs, etc.
Admin
Don't worry, Alex looks like Greek to me too
Admin
"I should have printed it out frist"
FTFY
Admin
Comment cOmment coMment comMent commEnt
oh whatever...
Admin
The most important thing is missing, of course ...
FILE_NOT_FOUND as seen here: [image]
Admin
Stop. stop. STOP. StOp. stoP.
Is it working yet?
Admin
Must be junor programer.
Admin
ToLower(), of course, being a method, not a class.
Admin
Not that I want to defend this piece of code, but the main criticism so far of it not accounting for things like sTart and such is almost unfair - they've accounted for any variation that a sane human might use. "START", "start" and "Start", for example. A casual glance at those and you wouldn't immediately think it's a typo (unless your coding style dictates that it is). However, if you looked at sTart, unless you're using Hungarian notation and have some sort of string Tart, then you'd immediately think it looks wrong.
Of course, that's besides the point in which this kind of boolean handling is just wrong.
Admin
Admin
you want the truth? you cant handle the truth
Admin
the truth is out there...
Admin
You'd argue no sane person'd do that, but on this keyboard, for example, my N key sometimes doesn't catch a hit, leaving the letter out. I'm sane (officially. Got a certificate saying I'm not nuts!), yet due to my N key, you can't trust my input will have the letter N where it should be.
Same goes for randomly capitalized characters. You can't simply assume nobody'll do that, as you just don't know the conditions in which it's written, nor the person writing it.
Admin
"The truth is out there"
beLieve
Admin
Case issues aside, we're still missing some obvious possibilities. We have yes/no, start/stop, on/off. What about yep/nope, yeah/nah, yes please/no thank you, 1/0, etc. Or maybe instead of start/stop someone tries go/stop. Point being, you need a pretty large dictionary to do this.
Admin
Or offshore Indian code. Same difference, really.
Admin
Clearly the problem is you forgot to handle for the third Boolean state.
True/False/NaN amirite?
Admin
Your sneakernet skillz are highly deficient, KY.
Admin
How do you know they did? You can only see the first few rows: those values are probably at the end, each one added separately in response to a ticket from a PHB who had trouble with his CapsLock key...
Admin
Well, they will happily find InvalidArgumentException in this case
Captcha: abigo. abistop.
Admin
isn't that "uts"
Admin
Admin
A certificate indicating that he is not insane is the result of a process which had cause to bring his sanity into question. That is, either he had been certified insane and gotten better, or had done or does do something which requires documentation that he is not insane officer, thank you for you kindness, but I'll be leaving the baby up on that lamppost this evening.
Admin
Admin
TRWTF is that there is no wooden table involved.
Admin
TRWTF is that you think ToLower() is a class ...
Admin
22 ways to express boolean values ought to be enough for anybody.
Admin
Admin
I love the comment:
Add as necessary. Now we know how this code came to be.
Admin
The REAL REAL WTF is all the ToLower() fanboys here, when ToUpper() is obviously superior. There's nothing a totally lowercase string can do, that a totally uppercase string can't do louder.
Admin
:D
Admin
Admin
Shouldn't the starts be false? I mean, for that company at least.
Admin
What language is this? Seems to come from Visual Studio. Is it Visual Basic?
Admin
I've done stuff like this in the past, but only when I'm converting a free-form field into a lookup or a particular type, and is always throwaway SQL code...
In fact, on my last project, I saw several instances where bool was represented as "Yes\No", "Open\Closed", etc., etc. The justification? "Oh, the client wanted to see that on the web page rather than a checkbox".... face-palm
Naturally, there was fragile logic throughout the code-base to convert to and from a bool where it would either look at the whole word, just the first character, ToUpper, ToLower, blah blah blah...
Admin
Admin
Like if someone cares about your faulty experience.
Admin
Admin
Admin
No, it also misses stuff like STart, FAlse, etc. which MS products automatically convert to Start, False, etc. It's so easy to mistime the removal of the finger from the SHift key (see?) when typing a word with the first letter capitalised. So you've got to add those too.
And don't forget, there's also "sTART" and "stART" etc. etc. for all those people who have forgotten they've left the caps lock on, and whose finger-timing is equally messy as that which has been specified above.
We also need to cater for variants on "sotp" and "satrt" etc, in case the fingers have got really fumbled, and also "ario" for the person who wanted to type "stop" but whose fingers were one key too far to the left.
So there's till plenty of work to do. I'd get Nagesh onto it straight away.
Admin
Admin
While we're at it, stqrt, stQRT, etc. as well, for people used to either a qwerty or an azerty keyboard and having to type on the other kind (triple that for Dvorak)
Admin
Admin
We are transported to Hater's bedroom [A dark, musty basement cluttered with old boxes and empty take-out containers. The only light provided is from an aging CRT monitor sitting atop a rickety Ikea computer desk, next to an impressive pile of used, um, facial tissues...]
Hater: "HA HA! I have him NOW!"
clickety click click
Hater reads to himself: "You are dum. Nobodi like yu"
PURE GENIUS!!!!
[The basement door opens.]
Hater's mom: Godammit Melvin! I told you to stop leaving your dirty underwear in the bathroom!
Melvin (aka Hater): Aw, come on mom, can't you see I'm busy?!
Admin
The developers behind this are well ahead of you, they have already put in a comment say // add as necesary. How much more future proof can you get?
I will share this amongst my team as an example of good development practice.