- 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
It's also validating that the code is operating under Option Base 0
Admin
Unless I'm very much mistaken,
<>
is the inequality operator in every dialect of Basic ever.Admin
I'm still wating for VB to implement the <=> comperator.
Admin
TRWTF is that TheDailyWTF automatically converts "VB.net" to a URL when it is written in an article (and yes, the vb.net domain is registered and there's a website there).
Admin
Actually, that's my markdown processor being "helpful", and me forgetting that it does it.
Admin
It also works in T-SQL (although != also works there).
There's no good reason not to use <> in my opinion -- before HTML/XML took over the world, that is.
Admin
To be fair, omelettes are much tastier than wheels.
Admin
This is the second recent WTF when the code counts something in a loop instead of checking the count property. It's almost as if there's a class of developers who still think on preschool level - "okay Johnny, let's count, 1, 2, 3, ..."
Admin
Without context, I had assumed
fileData
was a function. It doesn't help that VB.NET uses the same syntax for function calls and array access...Admin
BASIC adopted parenthesis syntax for array access from Fortran, so it has decent pedigree.
While the loop is a WTF itself, there's more WTFery in the way it loops. Try/catch should be outside the loop, so the loop ends once it discovers the error (or it should use
Exit
to break out of the loop in theCatch
). And it should loop down from 4 so the failure is caught as soon as possible.Admin
I am unable rightly to apprehend the confusion of ideas that could produce this code.
Admin
Being explicit about what is commonplace in the programming language may not "hurt" in a functional sense, but it's nearly always a sign of worse things to come.
Admin
Not if they are wheels of cheese.
Admin
One, two, three, NaN, file not found, 95, 98, 2000, 10, 11 ... is it working?
Admin
And <> used to work in Python, back in the Good Old Days.
Admin
Obviously, a count property is going to count out the number of items. And you can never trust the in-built functions, so it is usually best to write it out yourself, just to be safe.
Admin
I love all the assumptions that have been added to this code to turn it into a WFT…
Assumption 1: fileData is just an array. As other commenters have mentioned, we don’t actually know that to be the case from this code snippet, it could be a function call. Perhaps, even, at one point in the history of the codebase, it was indeed a function.
Assumption 2: We don’t care about nulls. Why on earth would we not care about nulls? In my experience, someone stating confidently “we don’t need to worry about nulls” is basing that on the certain knowledge that the code producing the data will never return null… which might be true today, but who knows about tomorrow or yesterday?
Assumption 3: The ToString method is boring. Well, probably… but maybe it does some validation of whatever that particular data type is, and throws an exception if the data is not valid. Let face it, this is The Daily WTF… so for all we know, ToString is implemented with a database lookup to find a “friendly name” for something that’s just numeric in memory…
Admin
Personally I much prefer proper boolean logic with an explicit NOT operator such as the C family of languages has with their !. Indeed, I would go a step further and implement that operator as an alternative to combination operators. As in !> would be equivalent to <= and !< to => (both being available).
Admin
<>
is the standard SQL "not equals" operator.!=
is a non standard extension that is probably implemented by all modern SQL implementations. Until everybody decided their language should look like C,<>
was pretty much the standard inequality operator.Admin
Honestly I would make <> the BETWEEN operator. As in X <> (Y, Z) would be equivalent to writing Y < X < Z. And of course you'd also have >< as in X >< (Y, Z) = X > Y or X < Z and the obligatory !<> and !><.
Admin
Good point.
Admin
[Quote=LCrawford] It's also validating that the code is operating under Option Base 0. [/Quote] In earlier versions of VB, Option Base could be used to set if array indexes start at 0 or 1. In VB.Net, all arrays begin with index 0. Option Base has been removed.
Admin
You can think of an array as a function which takes an integer and returns a value. similarly you can think of a hashmap as a function which takes a key and returns a value.
in clojure the syntax for dereferencing an array or hashmap is the same as for calling a function, and in fact you can substitute an array or hashmap for a function as long as it contains all the keys that you need
Admin
Arguably, the root WTF is Microsoft thinking it was a good idea to use a domain name format for the names of a series of programming languages.
Admin
Maybe ToString fails if fileData(fileDataCount) is misconfigured? Still WTF, but maybe?
Admin
For completeness shouldn't there also be "greater than or not equal to" and "less than or not equal to" aka "right fish" ><> and "left fish" <>< ?
Admin
doesn't it also throw an exception if one of the elements of the array is null? Because they call ToString on it?