- 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
Truth not found?
Admin
"It's very clear they didn't think about whether or not they should do this." Well, there's your problem. Really, it is clear they didn't think. That often leads to the kinds of code that gets featured on this site, including this batch.
Admin
Given the use of the .ToLower modifier on fleetSuccess I'd suggest your optimism is misplaced and updateGroup returns a string containing one or more of [True, true, TrUe, True&True, FileNotFound, Etcetcetc].
I was trying to work out if the coder had simply been trying make some abstraction to hide away shocking functions he had no control over, but given the state of this shocker there's probably no need to look elsewhere.
I once worked with someone who did things like this. Someone else in the outfit thought it would help to send him on a course to learn regular expressions. Truly, some of the atrocities he created after that would make you want to dropkick a baby seal.
Admin
The updateGroup call launches nuclear warheads, therefore what type it returns (string) and whether it's limited to "true" or "false" is irrelevant - the world is basically over.
There, I explained it.
Admin
Don't forget this line too: return Json(fleetSuccess, JsonRequestBehavior.AllowGet);
So, that "true&&&true" (or some combination there of) is also included in the Json response? or something? <mind boggled>
Admin
+1 on the Jeff Goldblum comment !
Admin
Some animals are more truthy that others.
Admin
The '&&&' operator is a type-safe AND, similar to the strict '===' compare operator.
Admin
Maybe they couldn't use a boolean because it returns not just "true", "True", and "false", but sometimes "MostlyTrue" or "ProbablyButImNotSure".
Admin
So someone actually thought it was a good idea to teach a pyromaniac how to make fuel-air explosives?????
Don't get me wrong, regexes can be used for a lot of things where they are the right tool, but they should be used with care.....
Admin
Admin
I'd say RegEx was the right tool in this case, although sorting out the crummy inconsistent data feeds would have given better gains. Still I like RegExes, even if I am far from the worlds best with them, I always assume someone else will have to maintain my code later on and they may find them scary. Doesn't need a tutorial, but if you've, for instance, just munged together something to try and recognise and validate and format postal codes/zip codes where you can't make assumptions about what country they relate to ... well that would make my own eyes bleed coming back to it a few months later.
But to torture your analogy, he took his nice new fuel-air bomb skills, completely failed to understand the actual point, and designed a rather dangerous heating system. We had some quite complicated RegEx expressions which were generally incorrect or incomplete for the subject matter, then stitched together and "corrected" with standard boolean stuff and stringification. The myriad attempts at date handling alone would keep this site going for a month.