- 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
Where is "FileNotFound"?
Admin
Yes, that is terrible code. No, I don't want to work there.
Admin
Also, they can easily adapt this to cover FILE_NOT_FOUND, so that's a plus.
Admin
not to mention the isYesNo function is very badly named. I would expect it to return true if the parameter is of type YesNo
Admin
N̷̹̞͚̣͔̩̻͈͇̺̬̬͕̠̞̣͕̙̔̊̎̆͗̾̃̑̄̔̄͐̽̔̍̏̑͌̍̊̚͘̕͜͜͝O̵̥̭̦̊́Ǫ̵̛͉̯͚̱̮̫̱͙̮̘͙̬̫͈̭̱́̃̓̅̈́̍̎͌̽̾͋̎͋͐̈́̐̑̒̿̾̚ͅÔ̸̧̙̼͎̖͕̗͚͔̖͉͕̝͔̰͓̦̥̯̕͜͝O̶̢̩̼̱̺̍̐̀̐̈́͋̄͒̽͌̐̽͋͂̕͘͝͝Ȯ̸̟͗̀̓̌̿́̓͑̿̾͊̓̈́̈́͝͝Ò̶̡̡̟̰̫͉͇̞͔͎͚̩̳̥̫̺͖̠̘͇̳̫̪͔͆̈́̕͜͜Ơ̷͚̲̩̜̙̩͖͓̯̱͇̜̑͛̈̾̈̈́̅͆́̿̽̈́̄̍̌̽̀͆̆̕͝͠͠O̴̢̨̡̭͓̟̝͎̱̘̫̟̩̲̜͖̹̥͎͍̳̱̦͙͊͒̓́̀̃̃͂͋̀̏́͒̈́͑̌͐̋̕̚Ǫ̶͔̫̣̼̹̗͉̺̣͆̂Ȯ̴̲͎̼͖́̑̈́́͗̄̀́͆̏̈́̄͑͐̔̾̋͋͊́̀̕̕͝͝Ǫ̴̫̺̳̩̩̠͕̦͉̰̫̳͍̠̦̫͕̥̐Ó̵̙̗̖̤̘͚̪̒̂͌̐͂̉Ȯ̶̧̢͖͉͓̻̥̣̫̼̖̘̖̫̺̣̀̅̀́͐̇͊͑́̀͗̚͜Ơ̶̧̨͎͙͓̪̥͇̦̹̖͍͎͚̯̞̰̯̱̯̟̆̔̉̄̎̀́̃͂̊̆̃͒̄̋̒̈̋͑̑͆̒͠͝ͅO̶̢͉̤̟͖̣͚̻̠̳̟̦͈̣̗̩͈̯͌̍̑̄͌̕͜ͅO̵͚̿͆̔͑̈́̍̈́̓Ŏ̶̧̡̢̢̡͕̭͔̫̦̤͎̲̬̤̖͚̤͍͉͎̼͚͓̹̄̈͌͂͘͝Ǫ̵̧̢̲̹̞̩̟̗̙̗̳̦̣̼͈̣̖͎̫̭̱̱̙̼̹͗͆͑̌̀͛̅̀̓̈́͐̇̒̿̎͊̄͊̀̀̀̌̕̚͝͠͠ͅO̷̠͙̗͔̖̺̟̞͔͈̺̫̜̘̓̀͌́͛̃̽̎̈́̓̏̌͆̾͊̒̆̚̚͝͠͝͝͠͝O̵̧͈̬̯͚̪̺͙̫͉̲̣͕̙̣̫͛̌̌̽̽͂̀͛́͠ͅͅO̴̹͉̮͖̯̜̞͉̠̳͚̜͎͖̫͍̖̝̳͆̏̊͛̓̋́̿̑̇̉̎̿̾̆̃́̎̏͂͋́͗͂̓̓͜Ó̷̢̨̡̨͍̻̯̙̙͈̭̜̰̺̘̫͙̖̥̣̰͕͎̺̖͒͒
Admin
The most fun part is that it does not round-trip.
If you start with a truthy
YesNoType
, thentoYesNo(fromYesNo(myTrueValue))
will make it falsy, because it returnsYes
but compares only withY
.Admin
TRWTF is the code being double-indented. Every indent level is 2 tabs.
Admin
And where is the XML config file? It's gotta have an XML config file! Because this might be a multi-cultural app that needs "Oui" and "Non", right?
Admin
The indentation is a TDWTF issue, it happens all the time here.
Admin
It's a confounding function, because fromString() exists and is used everywhere else. So they added toYesNo() just for "Y" instead of having fromString() handle it…
Admin
There probably should be an entire category of issues at The Daily WTF, how not to handle yes/no. Not really related to this one, but a previous project I worked on used shell scripts to prompt for parameters for a process, then prompted if you wanted to continue ("Proceed? <y>es or <n>o?") Then, it compared the response to a CAPITAL N, which was the only exit condition. Type 'Y', it would continue. Type 'n', it would continue. Type 'No', it would continue. And the consequences of continuing when you didn't want to took a lot of work to unwind.
Admin
My assumption would be that the YesNoType comes from a XML binding framework (e.g. JAXB) for a third party schema that defines a xsd:string restriction with enum values of "Yes" and "No". But even these enums are proper Java enums with generated constants, so (unless you are marshalling them from/to XML yourself), you don't need to use the generated fromString() and toString() methods.
Admin
"In the tab-vs-4-spaces debate, I compromise by indenting by 4 tabs" is up there with array indexing starting at 0.5.
Admin
Funny detail: The title looks funnier here in the comments and in the RSS feed, because the joke gets lost when the webpage formats it in all-upper-case.
Admin
These guys would probably have a Cancel button, and when you pressed it you’d get a popup window with “Cancel: Are you sure? :with three possible answers :“Yes”, “No,” and “Cancel.”
Admin
Why was the YesNoType source code not included in the post? I bet it is a gem as well!