- 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
Dim First(5) First(0) = 5 ' F First(1) = 17 ' I First(2) = 8 ' R First(3) = 18 ' S First(4) = 19 ' T
Admin
TRWTF is no unicorn!
Admin
If only an episode of $(Children_tvShow) was bought to us by $array.
Captcha: wisi. Wise Indeed.
Admin
a bunch of people with names starting with Å, Ö and Ä are mightily upset
ps: the "alphabet" doesn't have 26 letters...
Admin
The way it runs through the loop 27 times to catch the 26 cases is a nice touch.
Although I can't help feeling that the code where it uses rptAlphabets could be even better than this. If it actually does, of course.
And then I'm wondering what they'd do if they had more S names than will fit on one screen, but had no Z names at all.
Admin
For switch is my favourite antipattern.
Admin
TRWTF is clearly the fact that the indentation for case 24 is different from that for the other cases. Consistency is important, otherwise if third parties see the code they are likely to accuse you of unprofessionalism.
The fact that the loop goes from 0 to 26 is a minor issue that ought to be fixable by adding a do-nothing "default" option to the case statement. I would not dare to change the index to 25 like some of you gung-ho code-monkeys for fear of breaking something.
Apart from that, nothing to see here, move along, this code is perfectly cromulent.
Admin
They could put your name in backwards, that would cure that.
Admin
This code appears to be VB.Net, ADO.Net, and populating an ASP.Net repeater data control.
Many directories also have entries for 'Mc', etc. which would only slightly complicate the loop that could be written. And it would be nice to test for letters that don't have entries.
Admin
I am reminded of a tale my (poor, dead) mother told, about when she was working as a temporary clerical officer back in the days before computers when there was plenty of this sort of work about. A colleague of hers was tasked with arranging a large number of items into alphabetical order, so as to create an index. She did this by first creating a list of everything starting with A, then everything starting with B, then ... etc. She announced she had finished in a remarkably short time. Then the results of her work were inspected. It transpired that she did not actually understand that "alphabetical order" was a more technically involved concept than just "sorting into sets indexed by first letter". What was worse was that however hard dear mummy tried to explain the concept, the colleague in question could not understand what "alphabetical order" actually means.
Oh how we laughed.
Admin
I can understand the reasons why a newbie might think that writing a constant array in order to iterate over it once and insert the contents into a data structure is a waste of space, but I can also understand that those reasons are WRONG.
Not least, what do they think all those 'A', 'B' string/character literals are doing?
Admin
Hell I only read tdwtf for Remy's HTML comments anyway these days.
Admin
This is a sterling example of hardened Enterprisey code. One never knows when the Alphabet Committee would introduce new letters and as such is beautifully future-proofed as well.
Admin
In this case, handing her back all cards of the letter 'A' with the words "now you sort these by the second letter in that word over there" would probably do the trick.
You will then have to repeat this a few more times while keeping track of smaller and smaller packages of cards and at some point in the future you will have an alphabetically sorted set of cards.
Of course getting a replacement co-worker would be smarter but what if you can't do that because the poor gal is the president's daughter?
Admin
Who knows what else they might come up with?
Admin
Apropos of nothing in particular, my (poor, dead) mummy taught us the alphabet song as children, since television had only recently been invented, and Kermit the Frog was not even a tadpole. After we had tried to imitate her, she would recite the alphabet backwards.
This amazed us children, and when we asked her how and why she had learned to do this, she told us she had just felt like it. Only later did we learn that she had been involved in code breaking for the Navy in WWII (at age 25), which went a long way towards explaining her daily crossword puzzle habit as well...
Miss you, Mum.
Admin
How about generating the letter directory based on the results of a SQL query like:
Admin
But apart from the already mentioned loop boundaries, and, of the course, the existence of said loop in the first place, where's the wtf?
This is a lookup-table. I can easily envision other columns apart from "Alphabets". What, for instance, about column "ASCII":
Or "Etymology":
Who knows what the code does, that needs today's snippet?
Admin
Also past proof as well. Should work with EBDIC (where 'A'-'Z' is not a contiguous run) as well as ASCII derived character sets.
Admin
Not much of a lookup-table here, I'm afraid. And with the possibility of being incomplete - what if people whose names start with e.g. "X" don't exist in your database?
Admin
This actually happened just a few years ago in Sweden. The Swedish Academy formally decided to recognize W as an independent character (it was previously equivalent with V here in Sweden). So the 28 letter alphabet we used to have suddenly became 29 letters long.
Admin
Admin
Yours:
Theirs:
Admin
It also accounts for the names that start with letters that appear in the UTF-8 scheme (assuming your database stores that kind of data).
Admin
This code is not scalable. What happens when more letters are added to the alphabet in the future?
Admin
Who put the alphabet into order, eh? What criteria do you think they used?
Admin
Admin
Admin
This is one of the German language's many WTFeries, because 'ß' is derived from 'sz' (as can be seen from the HTML escape for it); but it is pronounced as if it were 'ss', and that's why the current substitution is made.
Admin
I thought that was just coincidence.
Admin
I know how to fix this
amirite?
Admin
You young whippersnappers can get off my lawn. When I was a kid, we used READ/DATA statements, and we loved it!
Public Sub CreateAlphabets() Dim tempTable As New DataTable tempTable.Columns.Add("ID") tempTable.Columns.Add("Alphabets")
On Error Resume 11000 Restore 10000 10000 Data "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
Dim dr As DataRow dr = tempTable.NewRow
Read dr.Item("ID") dr.Item("Alphabets") = dr.Item("ID") tempTable.Rows.Add(dr) Goto 10000
11000 On Error Resume Next Me.rptAlphabets.DataSource = tempTable Me.rptAlphabets.DataBind() End Sub
I even got rid of that pesky unneeded "i" variable, saving you 7 bytes of memory! That's 4 for a single-precision float, 2 for the variable name, and 1 for the variable type!
Admin
Admin
I live in Canada near the US border so we have both Zee and Zed in our alphabet!!!
Admin
Admin
We have such issues in Hawaiian with the kahako and
okina. We decided on the following collation: L1. Kahako and
okina are ignored unless all other letters are the same L2. A vowel followed by a kahako follows the same vowel not followed by a kahako L3. A vowel preceded by anokina follows the same vowel not preceded by an
okinaOhana</i> is therefore located under <i>O</i> and <i>La
ie follows LaieAdmin
interesting...I too live very close to the US border in Canada; I have found the same thing using both Zee and Zed for the last letter of the alphabet. As well as other interesting things like Soda or Pop etc...
South West AB
Admin
TRWTF is that they call letters 'alphabets'!
http://phonetic-blog.blogspot.com/2010/07/alphabets.html
CAPTCHA: secundum (wait a secundum!)
Admin
This may be dependent on language, but it appears that you have an empty item in your array.
Let me fix that for you:
Admin
TRWTF is chubertdev and languages for which they are correct.
Captcha: validus. chubertdev is not validus.
Admin
Nah... Your mom was a raging alcoholic that was well practiced in beating field sobriety tests. You left out the part where she stood on one leg, eyes closed, and touched her nose.
Admin
Bubblehead sort?
Admin
I'm glad that you gave examples to prove your point.
Admin
Well, but those people would be foreigners, so who cares?
Admin
FTFY
All these 'off by one' errors do add up. Sometimes they can cancel out if you aren't careful.
Admin
One of the teachers at my high school wrote an attendance program that kept the data in READ/DATA statements.
Updating the data base? Well, this was a Commodore PET, which had full-screen editing. When you pressed ENTER, it would look in the screen memory to see what you had typed and execute it. So he updated the database by poking the updates in the screen memory and then poked an ENTER into the typeahead buffer. This would add the new DATA statements to the program, which the secretary would then save to cassette for use tomorrow.
READ/DATA with a self-modifying BASIC program. And we loved it. Try to tell the kids that these days...
Admin
Admin
I'd be more impressed if she stood on one eye, nose closed, and touched her leg.
Admin
Not sure if your version would have supported it, but mine allowed you to omit the spaces and quotation marks, which made it a little better...
Admin
In all the languages I know, the case/switch/select construct has an implicit do-nothing default if a default is not given. Is VB different?