- 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
Sometimes I wonder if some of these code samples were made up by submitters to amuse the audience. This one definitely wasn't - it takes true dedication; "you can't make this up".
Admin
No visible loops even needed: Enumerable.Range(0, checks).Select(x => "").Add(checkersummary);
Admin
In the original code if you use a number greater than 19 it behaves as if 0. The Range won´t do that will it?
Admin
TRWTF is needing to set up an array with a specific number (up to 16) empty strings in the first place. We haven't needed to do this sort of thing since Fortran, surely. If your code design does make it necessary to perform this sort of exercise, there's a dead rat with halitosis buried in an excrement and garlic sandwich buried somewhere else in your application.
Admin
Or sitting in between your chair and keyboard. Or perhaps more terrifying between your bosses chair and his keyboard.
Admin
I suspect the reason that checkersummary is at the end is that the desired return array is mutable.
That is to say, this horrid thing is the default state, and an indeterminate number of calling sites are going to insert the checker of their choice at the point of their choice.
The stenchometer is high on this one, isn't it?
Admin
That doesn't look like a true WTF - more like an early indicator of a huge toxic pool of WTFs deeper in the code.
Admin
This is less about FOR LOOPS and more about not using an array object for all of the values. Besides, why not just build a specific object? Why use the default object? Asking for a friend. I am not a Java programmer.
Admin
"If your code design does make it necessary to perform this sort of exercise, there's a dead rat with halitosis buried in an excrement and garlic sandwich buried somewhere else in your application."
You, sir (or madam) win the Internet for today
Admin
It only takes a minute to generate the code in Excel
Admin
At first, I was trying to figure out what this is used for.
Initially I thought it was doing a string pad of a value. But then noticed that it was creating an array of object to return.
Perhaps there is some reason why there can only be up to 19 empty entries in the array. Or maybe this will end up being another case of 'we need you to add more days'.
Given the names of variables, it is possible that this has something to do with testing. Either code testing, or actually testing user input during runtime in production.
But then I realized that down that path lies madness. I'm just going to close my browser tab now.
Admin
Writing code in Excel? That's a major WTF all by itself.
Admin
FWIW, this is C# - it's
Object
with a capital O in Java.Admin
And quite possibly, for the rest of the week.
Most excellent code review. Worthy of a sidebar :)
Admin
Fortran dev here. I feel the pain...
Admin
You can use a loop to fill it, you can't use a loop to create it. I think the programmer didn't realize how to make an array of different types.
Thus:
object[] Result = new object[checks + 1]; for (int Loop = 0; Loop < checks; Loop++) Result[Loop] = ""; Result[Checks - 1] = checkerSummary; return Result;
Admin
Yeah but C# code using K&R brace placement? That's TRWTF right there.
Admin
Write yourself a little prettifier in something like Python. Job done. Quit bitching.
Admin
It happens to be valid C++20 as well, thanks to https://wg21.link/p1009r2.
Admin
Any jobs going where you work?
Admin
I like this "benefit of the doubt" section - gets your mind rolling. Could be a stable feature of your blog posts from now on...
Admin
This reminds me of some code I wrote back in middle school. I was writing a digital version of the board game mastermind. Mastermind has 44 different holes that differently colored pegs could go in. I knew about loops but I didn't know about arrays, and I wished that I could iterate over my 44 different "hole_row_10_column_4" variables in some way. If I had been using a language with eval, I probably would have made liberal use of it.
Admin
I remember using an older version of Visual Studio with C++ (2010?), and it wouldn't let you specify an array size at run time. Maybe the coder for today's WTF is used to coding with such restrictions. But then the WTF is not RTFM and being aware of what is permitted by the current language.
In my case, if you needed dynamically sized arrays, you would just use a vector (and do so for just about any use-case requiring arrays anyway). Even if C# (which I'm guessing is the language here) didn't allow you to have arrays of size unknown at compile time, they still have Lists and other containers.
The bigger WTF is why this array is even needed, in the format used, which we'll never know sadly.
Admin
I'm pretty sure the empty strings is just a lazy way to avoid having to do null checks in the consuming code.
Admin
I assume you mean C-style arrays. Runtime sized array would be C99 feature and this particular feature is not supported by any version of MSVC. IIRC for a long time C99 wasn't referenced by C++ specification. (Only C89 was)
Note: Current MSVC has switch for support for C17. Maybe Intellisense hasn't been updated for runtime specified arrays.
Admin
I find your comments suggesting things seemed made up on some of the least contrived examples. So I guess it's fair that you've left this comment on one of the easiest examples I've seen to make up.
Admittedly, I've seen code very similar to this in the wild, so I'm not saying this was made up. But anyone with knowledge of for loops and knowledge of the existence of people who don't know about them could come up with this relatively quickly in most languages with for loops.
Admin
I'm guessing - it started out as needing perhaps just the first two, and they were separate for testing. Everything worked, and it was left as is. Then someone said another option was needed, and added a new line. Then another one, and another one, and there's probably a comment somewhere saying "when you add another widget don't forget to add another line to this bit of code"
Admin
In the real-time world, it's extremely common to abjure dynamic memory allocation (or more accurately to roll your own using fixed-size data structures as memory pools). Even so, it's obvious that the checkerSummary is of a different type from other elements of the array, and should be factored out.
Admin
wonderful issues altogether, you sjmply won a emblem new reader. What would you sugest inn regards to your post that yyou simply msde some days in the past? Any certain? https://Www.waste-Ndc.pro/community/profile/tressa79906983/