- 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
Wouldn't it simply not compile if value wasn't a bool? The property is defined as a bool, therefor, value will always be a bool, no?
p.s. forgive the previous screw up
Admin
Some appear to miss the value point of this code.
You outsource to "save" money. Yes the code could have been written in much fewer lines of code, but the more lines of code for the same amount of money is considered a "value". IE:
6 lines of code per property sets and gets for $6 @ $1 per line.
or
24 lines of code per property sets and gets for $6 @ .25 cents per line
The idiots that hire them see the latter as a better investment, besides the other outsource company was charging .75 cents per line of code right...
Admin
Pssht... Just string and regex it... [;)] Wait, that's not the "enterprise" solution...
Admin
// Here's a patch for a bug I found in their code:
throw new ProgrammerIsAMoronError(true);
Admin
On second thought. I think this was written by a former therapist. It's 'true' or 'false' or 'what do you think (...err feel) the answer should be?'
Admin
*sigh* Another incarnation of IsTrue(). How funny.
Admin
Now THERE'S truth in advertising.
Admin
Fortunately, Microsoft plans for such foolishness, and Boolean's ToString is never localized, and always returns "True" or "False" regardless of the culture setting:
Displays:
Admin
null
or maybe an error object.
perhaps the origional function returned a Variant (Varient? whatever)
Admin
Well, that just made a mess of my code. Let's try this again:
public static void Main()
{
IFormatProvider french = new CultureInfo("fr-FR");
Console.WriteLine(DateTime.Now.ToString("D", french));
Console.WriteLine(true.ToString(french));
}
Admin
I wonder what these functions look like (I'm sure they have them)
IsTrue();
IsFalse();
IsTrueOrFalse();
IsNotTrueOrFalse();
Admin
It is really impressive how bad this outsorced code is. If they really cared about this project they would know that if(m_ISO9001.ToString().ToUpper() == "TRUE") actually creates two new strings in memory on top of the boolean value that it is representing AND the "TRUE". To get a truly optimized compare that will compare without case sensitivity, any real developer knows you should use if(string.Compare(m_ISO9001.ToString(), "TRUE", true) == 0). This only creates one extra string in memory. That is a 50% increase in performance!!!
Admin
Yeah, sorry, I was just going for the quick answer. You would get a compilation error.
Admin
What you say is very file not found, very file not found indeed.
Admin
I'm (blnSure = .1) sure you're right
Admin
Perhaps it's pay-by-line billing, and the contractor is counting on not being spot-checked. After all, more code means it must be a better product!
Admin
Are you sure that each call to bool.ToString() creates a new string? Why the hell should they do that?
Admin
I think this wtf proves the Infinite Monkey Theorem.
Admin
if (quotedPost.isSarcasm().toString().toUpper() == 'FALSE') {
say("Where else would they put it? Mars?");
}
else if (quotedPost.isSarcasm().toString().toUpper() == 'TRUE') {
quotedPost.append("</sarcasm>");
sarcasmDetector.fix();
}
else {
throw new ThisIsReallyAWtfException();
}
Admin
Yah, that'd be like totally cool. and with all of the extra little bracket thingies it creates even more lines so it'd be like infinity billion + a whole bunch!
Admin
My first reaction was to say the code was complete developer-is-an-idiot crap. My second thought was the developer was being paid by the KLOC. But the name of the property, ISO9001, has me wondering. Could some manager have forced the developer to do this in the name ISO9001 compliancy? Or could this be a developer trying to be recursively funny and putting all this redundancy stuff in there because the property is name ISO9001.
With any other property name, I'd call out WTF or KLOC. But I too am wondering if this is CMM 5 humor. Heck, I'd be tempted to do something like this in an attempt to bring humor into my life if I was forced to be ISO9001 compliant with no good reason. Whether this is WTF, KLOC, or ISO induced, I think Scotty has the best description of the situation.
Cap'n, I canna give you warp nine much longa - she's gonna blow
Admin
What you're proposing is reasonable. But it violates Hanlon's Razor:
http://en.wikipedia.org/wiki/Hanlon%27s_razor
Even so, I can follow your logic. The code does look like a smart-ass way to "test for every possible condition," perhaps in response to some reviewer who was not convinced that true and false are all of the possible conditions for a boolean.
But, in accordance with Hanlon's Razor, and maybe even Occam's Razor, stupidity seems to be a more plausible explanation.
Perhaps at one time, the property was declared as a string, and whoever changed it, well, wanted to change as little as possible. That is very plausible, as I've seen people declare boolean attributes as strings and also as integers in both Java and C#.
Admin
You've got it. The WTF is, of course, that they failed to validate the boolean result of the comparison on the string result.
*facepalm*
Admin
<font face="Lucida Console" size="2">Quoting W:
<?php // I like PHP<br>function isValidInt($variable)
{
if ($variable == 0) { return true; }
elseif ($variable < 0) { return isValidInt($variable + 1) }
elseif ($variable > 0) { return isValidInt($variable - 1) }
else { return false; }
}
?>
Somewhat ironically that function does not actually work. Because of PHP's automatic type conversion, isValidInt(false) would return true. (after you add in the missing semicolons of course)
</font>
Admin
This is the kind of WTF that you get when someone doesn't grasp the distinction between compile time and runtime, and doesn't care to ask.
The thought process was probably like this: "A program's source code is a string, so the names of the boolean values are also strings. When someone passes true or false to my function, they're passing a string. But what if they pass something else? I'd better check."
It also shows that masochistic attitude toward coding that we see from so many F-heads.
Admin
Why would they do that? How do you get a localized version of true or false?
Admin
Oh yes, and Perl sucks because it rewards such thinking. I shouldn't pass up a perfect chance to dump on Perl.
Admin
Totally fake, but amusing regardless.
Admin
The scariest part of this code is the "ISO9001" name - I wouldn't be surprised if this outsourcing company's secret to success is that they do ISO 9001 compliance - and this is what ISO 9001 compliance means. Yikes.
Admin
Wow, Performance-Penalty for upcasing the String and matching it with a constant for an operation that checks one bit.
disgusting
Admin
Admin
Think so? I've spent plenty of time answering newbie questions about C. I wish I had a nickel from everyone who has asked me why "int n = argv[1];" doesn't work.
Admin
Problem solved:
<FONT face="Courier New" size=2>if(!true && !false) { return 'file not found'; } else { return new MooseManager(); } // good to go.</FONT>
_______________________________
I really like MOOSE. It's so versatile. How 'bout y'all?
[^o)]
Admin
While I am not familiar with C# in particular, it would seem reasonable that since the .ToString() function is returning a value, then it has to exist in memory somewhere. And since it exist in memory, it must have been created at some point, and I highly doubt C# would just keep static versions of the true/false strings just for the heck of it.
Admin
You're probably the only one; I think most people would stop at "it might be a forum when it's finished".
Admin
No. You should keep the possible string combinations in a relational database table -- HELLO!!!!! And look them up by key. I strongly suggest using a GUID, because you can generate an infinite number of them, right?
Admin
At most, it would be created once, and, hopefully, on the stack: according to the MSDN documentation, both TrueString and FalseString
are shared/static fields of a boolean. (Hopefully, of course, Boolean.ToString does something analogus to . MSDN seems to suggest that as the case.)
(Here's hoping this works proper.)
Admin
A few comments
1- If you can't trust the CLR to give you bool values that are either true or false, then can you really trust the string comparison operator to work?
2- The setter is a real beauty (creating an unecessary variable, upper casing the string twice). I guess if you don't understand boolean types, there probably isn't a whole lot that you are good at.
3- Ironic that the purpose of this POS code is to return whether ISO9001 quality standards are in effect. I would say based on the code, the answer to the question is always no.
H^2
Admin
This actually makes sense. Probably the value is coming from user input, and he doesn't trust the calling program to validate data before calling the routine.
Like maybe it's a web application and it's using calls like
A malicious user could run "calc" and compute 0/0, which returns NaN ("not a number"). Then they could cut-and-paste to replace "true" with "NaN" and corrupt the database. (This is a subtle exploit that a lot of programmers don't seem to know about. If you pass the literal string "NaN", then it evaluates to "true" because it's non-zero. But if you run "calc" and copy over the representation of 0/0, then you've got a value that's zero and non-zero simultaneously.)
Admin
Admin
Maybe it is just a joke on behalf of ISO9001? Because that standard does not improve the quality, it only forces to document the stupidity.
Admin
Except in VB.Net, where True will be -1...
Admin
Darn; missed the quote bit! above relates to:
<quote>Think of it as a float, constrained to a value between 0 and 1. 0=false, 1=true, 0.5=maybe, 0.2=rather not, 0.9=most likely etc.</quote>
Admin
If -1=true, then -0.5=maybe etc. That's not a big issue. I think implicit casting between bool and float is not enterprisy anyway.
Admin
To be exact, the fact that the property, of which this code is the setter portion, is defined as a bool means that the attempt to assign to the property a value which is not bool and can not (implicitly) be cast to to it (as in SomeObject.ISO9001 = "FileNotFound") would already result in a compiler error, so "value" in the code above can safely be assumed to always be a bool.
Admin
I suspect you use a generator for these Boolean-WTF's - admit it! :-)
I wonder when we will be through all combinations it can produce :-)
Admin
Actually, it wouldn't throw an exception here. value is already guaranteed to be a boolean. It would happen before here in the assignment as either a compiler error or an invalid cast.
Admin
3- Ironic that the purpose of this POS code is to return whether ISO9001 quality standards are in effect. I would say based on the code, the answer to the question is always no.
ISO "quality" standards have very little to do with quality. If you do the same crap every time, and its documented, you're ISO-approved. So you could put the crap around every boolean, have a 20 page document explaining it and you'd pass your ISO audit with flying colours.
Admin
this wtf reminds me of the "When (n<0) wont't do" wtf.
Admin
Yes, it would appear that it does.