- 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
Wups sorry, I should have been responding to the initial posting, not your response.
Admin
Well, based on the above, seems to me the else would be as unpredictable as the IF. :)
Admin
Wrong, ELSE will be much more predictable because you always know it's opposite to IF, thus decreasing entropy.
Probability theory FTW
Admin
Depends what you want the default behaviour to be for the particular database table. Usually when you have to specifically select a property to be enabled, then absence of that value would assume disabled to be the norm. The logic would go: "Does this database field contain a synonym for 'affirmative'?" Then that feature is enabled. If not, it's disabled." Can be effective if you want to do a staged upgrade.
At your leisure you then go through and set that property for the (old) projects which do not have that feature enabled to "N". When all the projects have been so treated, you can then issue an upgrade to your system such that the default is now "Y", and then you ask the specific question: "Does this database field contain a synonym for 'negative'?" Then that feature is specifically disabled, and any new projects (which will have that new feature by default) do not need to have that property added.
It was a technique that proved workable when we had a few hundred projects to provide a service for, many of which, on project initiation, required certain significant enhancements which then became selling points for future projects and were therefore included from then on as a matter of course.
Admin
Go the fuck from here dumbass brithead
Y/Yes
Admin
Admin
Admin
You have failed at ousting a single user. Why don't you go back to fourchan or reddit or whatever?
Admin
Worse to you dickhead.
That's only beginning.
Admin
Actually, We can handle the truth. We can also handle the Truth, and the TRUTH.
We can't handle the tRuth, the trUth, the truTh, the trutH, the TRuth.....
Admin
Were they trying to protect industrial secrets. Our their own reputation? If this us the most valuable code you could find to steal I suspect the latter.
Admin
I've imported data from optically scanned written forms that required far worse than this. How many people do you think would have a tild(~) in their names? I suspect that they would need to add other forms of truth like OK, nope, yeah, and whatnot.
Admin
Nono, we just haven't yet been shown the method that does the checking yet. That's where the toLower() "class" is found, and you will see that it handles the "trUe" case just fine:
Admin
"nO, yEs, yeS, yES, YeS, YEs"..
Copied from the sound track of a p()rn0 video...
Admin
All quite sensible, yes; and we're doing that, sort of. Our approach is more along the lines of, "Ensure the database has an explicit value to begin with." That way, the contradictory assumptions don't matter.
At the moment, it's easier that way because the number of places where a column is loaded/updated is usually far fewer than where the value is referenced.
Fortunately, our environment doesn't leave us with multiple versions to support.
Admin
Matt Westwood (Unregistered) is not Matt Westwood. I was going to ignore the pillock from now on in the hope that he'd die of malnutrition. Just leave it, yeah?
Admin
Actually no, this is like shooting fish in a barrel.
It's meaningless to you because you're thick as pigshit.
Admin
What's hilarious is that it's not even a dictionary. It's an array of what I can only guess are some sort of tuple. There are no lookups here, just iteration... :(
Admin
TRWTF is that nobody realised this is C++ code and that StringSettingBool is probably a struct.
Either way, I think the following solution displays the superiority of C++ over petty languages like C# or Java in many ways. Albeit, it doesn't remove the fact that the "Truth Enough" snippet is a disgrace to any respectable C++ programmer.
Admin
Admin
It looks as if there is code that can determine exactly what inputs are accepted as meaning true or false, and which are not accepted. If that is what is intended, then the code is absolutely fine, maybe a bit short of documentation, and the WTF is our informant not knowing the spec for the function and making ASS umptions. It looks quite sensible that "yEs" should not be an acceptable input. At the moment I could implement this easily with a bit of code, but the method used is simple enough, and easily adapted to requirement changes.
The informant should be fired immediately. If his employer is security conscious, that's not for him to judge. It is for him to accept it, or to look for a job elsewhere. In no case should he have taken screenshots of code that they don't want anyone outside the company to see, and posted it here.
Admin
CAPTCHA: sino Because it would be an arch-sino!
Admin
Admin
tldr;
TRWF is not knowing you're meme! Know you're meme!
-> I can't see what's wrong with that code! Did anyone of you bitches read the specs? -> The first rule of the fight club: etc...Admin
Zune, how about being ass-raped by the legendary meme Tony the pony while seeing me copulate with this ungulate?
Admin
Admin
Admin
using System; using System.Linq; using NUnit.Framework;
namespace CodeSnippets { public static class StringParser { public static bool? ParseToBoolean(this string text) { if (string.IsNullOrWhiteSpace(text)) { return null; } string[] trueStrings = {"yes", "on", "start", "1"}; string[] falseStrings = {"no", "off", "stop", "0", "-1"}; if (trueStrings.Any(o => o.Equals(text,StringComparison.InvariantCultureIgnoreCase))) { return true; } if (falseStrings.Any(o => o.Equals(text,StringComparison.InvariantCultureIgnoreCase))) { return false; } return null; } }
}
Admin
Admin
Mandatory morning pony
[image]Admin
:) I was going to say the same thing ParkinT - What about yEs!
Admin
Admin
No - the right one, where you can meet dinosaur in the street with 50% chance.
Admin
Except, the reality is that you should never, NEVER let users type in replies like this unless there is ABSOLUTELY no way around it (like console-based applications). This is why checkbox, radio button, and select controls were created; to funnel known answers to known inputs. Keep it simple I say.
Admin
Admin
Why?
Admin
Admin
Admin
Right so you're using a PDF . and you think there is no WTF ? That's not flexibility, it's failability.
Admin
While this sort of Boolean coding may appear "wrong", sometimes you have code already existing with these values as settings and sometimes people are already used to calling one thing "stop/start" another "True/False" another "1/0" and another "Y/N" before even taking the project to a computer.
What's so wrong about letting people speak what comes naturally to them? Everybody thinks Siri is wonderful.
Admin
Not really. There's at least a modicum of hope for improvement/growth/learning from a "junor programer".
Admin
It's "I'll be sure to follow up", not "I'll be sure to follow-up".
I know it's industry practice here to mangle a verb and an adverb into weeaboo "verbs" like that, but just stop it. All of you. Learn to use English even if it is not your native language, and especially if it is.
You don't "setup" anything and you don't "follow-up" anything. Those are substantives, not verbs.
Admin
yes/no/NaN/Null/FileNotFoundFileDeletedOrNotEnoghSpace
Admin
Aside from the fact that they should have each stored only once, and then call tolower on whatever they're comparing, there's nothing wrong with this. I have code to do this myself.
Admin
It's a straightforward fix; just go through the OED and for each word in it, decide whether that word should map to true or false. Other languages do something similar with gender, so it's not unprecedented. ;)
Admin
Everyone is missing the beauty here - when you are too afraid to call a utility function in your own code due to the possibility of side effects, you use a map like this.
;)
Problem is, it isn't a map, but an array.
If it is C#, then it is much more fun to extend the string class:
Admin
My God, its full of stars! Hows about:
Whats needed is to extend string so it has a .Has method that takes care of "" and eliminates s+"x" weirdness.
So ultimately it could be written:
Or even:
And the best part is -- you can read it at a glance and know you got it right!
Admin
It's lacking 1/0 which I would be muuuucccch more likely to assign to a bool than yes or no. And it's lacking the VBScript -1/0, which is probably for the best.
Admin
If you're in trouble he will save the day He's brave and he's fearless come what may Without him the mission would go astray He's Arnold, Arnold, Arnold Rimmer
Without him life would be much grimmer He's handsome, trim, and no-one slimmer He will never need a zimmer He's Arnold, Arnold, Arnold Rimmer
More reliable than a garden trimmer He's never been mistaken for Yul Brynner He's not bald, and his head doesn't glimmer
Master of the wit and the repartee His command of space directives is uncanny How come he's such a genius? Don't ask me! Ask Arnold, Arnold, Arnold Rimmer
He's also a fantastic swimmer And if you play your cards right Then he just might come round for dinner He's Arnold, Arnold, Arnold Rimmer
No rhymes left now apart from quimmer He'd better fade us out before we get to schlimmer Fade out you stupid plimmer.
Admin
They also forgot: nO, yEs, yES, yeS (...) to cover up all the possibilities.