- 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
Though the code at present does not show it, the char array split allows for better processing of " to" "to" "to " " to ".....
Admin
@Remy: Formatting blooper for Niels H*
Also:
Startdate
being the end is a really bad data model smell.Admin
Bad naming ✅️
Wrong type ✅️
Invalid data ✅️
Incorrect usage of API ✅️
I approve of this WTF. Pretty good
Admin
Create a view in the DB and let the DB do let the heavy lifting.
But the story reminds me of when I was working for a major funds manager. We had a table in the DB with an int column aptly named "day_of_week". I had a look in the table and expected values 0 .. 6 (or maybe 1 .. 7) but oddly enough spotted values like 15, 18 etc. I asked one of the seniors what happened there. His reply:"Ah, that column, erm, yes, cough, someone gave it a wrong name when we started it. And then it was too late to change everything.". Instant classic.
Admin
@Mr. TA : You forgot one:
Admin
I have a different explanation I have seen in the wild - learning while working. He noticed how overloaded it was and wanted to experiment with that. Tried a few options. Satisfied he wanted to move on with the code. As it happens, the result of his last experiment was... usable, so instead of changing to a more correct solution, he grabbed the right index and continued. The resulting code worked, so job done.
There's nothing strictly wrong with learning while working, as long as it doesn't waste more time than it saves in the long run. But if you have no code reviews and programmers can make architectural decisions... you end up with accidentally working "learning experiments" in production, and things like tools and libraries chosen based on "I always wanted to learn this one, and I think I can make it do what is needed here".
I've seen this. The library choices were really wrong, but (brutally forced) did the job, the whole thing worked, so noone cared - except us, who had to support the monster.
Admin
I had the check the docs on
int.Parse()
to see if it'd be able to handle"08"
or"09"
correctly: a lot of parsers would try to parse those as octal and then throw an exception when they saw a non-octal digit; but in this case it seems that the parser does not support octal and will correctly strip the leading zeroes, so to my surprise that's not an additional WTF.Admin
I second this. I do this sort of thing all the time. Especially when experimenting with the API of some new or otherwise odd library we have to use by management fiat.
I make a point of calling all my variables for such testing really stupid things like "bob" so as to make sure they can't possibly pass code review.
Admin
Hey, at least they didn't use the horrid MM-DD-YYYY date format, so that's something... Otherwise, pretty good WTF overall.
Admin
Presumably also coded before the introduction of LINQ, since Temp1.First() and .Last() would make this nonsense a bit more clear.
Admin
Indeed. The only acceptable date input formats are UTC ISO YYYY-MM-DD or the French Revolutionary Calendar.
Admin
There is a good reason why that someone left.
Admin
Note: Before the introduction of Linq to the person who wrote it, not necessarily before the introduction of it to the world.
Admin
The queries belch me up. / The parser spits me out. / From schemas tragic I am born again. / And now I'm with you now / Inside your world of woe.
— Parsing Temp Strings, "The End is the Start is the End"
Admin
Oh boy... sometimes I wonder who those people are writing stuff like that.
Admin
Who are they? At some point in our "careers" all of us. :)
Admin
Seeing the "ToCharArray" makes me think they've come from C++, where different methods in different libraries want strings in different ways (std::string, char*, just as starters).
Admin
The next "enhancement" will be to add
StringSplitOptions.RemoveEmptyEntries
so they get a two-element array, and it handles leading and trailing spaces as well.