• (cs)

    Oh, so the WTF is that php was used instead of asp.NET?

  • (cs) in reply to Coyne
    Coyne:
    If I were a cynic (which I am) I would wonder if the programmer gets kickbacks from a hardware manufacturer.
    As if any programmer would have enough business sense to even *try* to get a kickback.
  • regeya (unregistered) in reply to frits

    "Hi. I can't find Mikael Åkerfeldt's name in your address book."

    Now there's a name I never expected to see on TDWTF!

    Is Opeth way bigger in Europe than they are in the States? Every time I see a pic of him playing with that band, he's playing a different, really sweet Les Paul.

  • (cs)

    I know it's a WTF, but what was the original developer thinking!? Why not make it an array to begin with? Failing that, why not forgo the delimiter and use substring functions? Why not just use raw HTML since the alphabet obviously isn't coming from the database iself? Why? Why? WHY!?

  • (cs) in reply to Power Troll
    Power Troll:
    Oh, so the WTF is that php was used instead of asp.NET?
    Yes, because there are about a gazillion ways of doing this in ASP.Net that don't involve writing any code (and therefore, writing any WTF's like this).

    Telerik FTW.

  • Robb (unregistered) in reply to regeya
    regeya:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."

    Now there's a name I never expected to see on TDWTF!

    Is Opeth way bigger in Europe than they are in the States? Every time I see a pic of him playing with that band, he's playing a different, really sweet Les Paul.

    He plays a Strat too and various PRS models.

  • Cromat (unregistered)

    While the story isn't all that interesting. It is hilarious that no one saw this coming. I don't think they bothered to load test it at all.

  • (cs) in reply to Cromat
    Cromat:
    While the story isn't all that interesting. It is hilarious that no one saw this coming. I don't think they bothered to load test it at all.

    They hired a graphics design shop to build their CMS. I'm thinking they aren't even really aware of what load testing is...

  • (cs) in reply to boh
    boh:
    Airhead:
    frits:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."
    Yeah, we don't care about accents, so it's listed under A.
    Except it isn't an accent - it's letter #27 in the Swedish alphabet.

    Or letter #26, if you take in the fact that 'v' and 'w' are basically the same letter in swedish, only spelled differently.

    I'm sure when the build a Swedish CMS they'll include those letter.

    For this English based CMS all names would be transcribed into English (rather than transliterated) and you'd only need the standard 26 characters.

  • (cs) in reply to hatterson

    What I LOVE about today's WTF is that it's clean, very easy to read, and so horribly, utterly wrong.

  • Tanuki (unregistered) in reply to boh
    boh:
    Airhead:
    frits:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."
    Yeah, we don't care about accents, so it's listed under A.
    Except it isn't an accent - it's letter #27 in the Swedish alphabet.

    Or letter #26, if you take in the fact that 'v' and 'w' are basically the same letter in swedish, only spelled differently.

    I want to furtherly illuminate that "letter #26, w and v are the same" thing, in case some didn't get it. Basically it means that for example in dictionaries and such alphabetical listings w and v are treated as alike, so Williams would come before Vilson. This is because Swedes don't used w in the native words and don't have separate sounds for them so looking from dictionary for v or w word, one would have to guess.

    The post also shows another Swedish feature: they capitalize only they Nation's name, not the language, as many languages have the name of the country in where they are spoken in, on can retain unambiguity in this way.

  • Mad Adder (unregistered) in reply to Xenon Xavior

    Or you could just cut out the middleman and do this:

    foreach(range('A', 'Z') as $letter) {

    ...

    }

  • davee123 (unregistered)

    I can't believe nobody's called the believability of this WTF into question! These comments are clearly fake!

    DaveE

  • (cs) in reply to Svenson
    Svenson:
    Airhead:
    frits:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."
    Yeah, we don't care about accents, so it's listed under A.

    That's not an accent. The last four letters of the Swedish alphabet are Z Å Ä Ö.

    ( In German, Ä Ö and Ü really are A, O, and U with diacritical marks and they sort exactly as the unaccented letters, which just goes to show how internationalization is a bitch... )

    Up to the last decade of the 20th century, sorting was a bitch in Spanish as well, because they insisted in calling "ch" a single letter, despite writing it as two separate letters. Thank god for IT, that made the RAE disavow that travesty of a "letter".
  • (cs) in reply to boh
    boh:
    Airhead:
    frits:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."
    Yeah, ve don't care about accents, so it's listed under A.
    Except it isn't an accent - it's letter #27 in the Svedish alphabet.

    Or letter #26, if you take in the fact that 'v' and 'w' are basically the same letter in svedish, only spelled differently.

    Vell, zat explains ze accent. In German, the letter 'v' seems to sound like 'f', while 'w' sounds like English 'v'; vhich is vhy Germans vill speak like that as they instinctively vill pronounce 'w' as 'v'. ;)

  • Yankee Doodle (unregistered)

    What's with all this internationalization anyway? Didn't anyone stop to think what a pain that would be? The Bible is written in English. 26 letters ought to be enough for anyone.

  • ClaudeSuck.de (unregistered)

    SELECT SUBSTR(LastName), Count() FROM Customers GROUP BY SUBSTR(LastName) HAVING Count() > 0 ORDER BY SUBSTR(LastName)

    Then loop over the resulting letters. However, in 120.000 names I would expect to see nearly all possible letters anyway. So you could just create a link for every possible letter (what about Cyrillic?), or the most likely ones (sorry Mr. Åkerfeldt), without checking the address book at all.

  • ClaudeSuck.de (unregistered) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    SELECT SUBSTR(LastName), Count(*) FROM Customers GROUP BY SUBSTR(LastName) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName)

    Then loop over the resulting letters. However, in 120.000 names I would expect to see nearly all possible letters anyway. So you could just create a link for every possible letter (what about Cyrillic?), or the most likely ones (sorry Mr. Åkerfeldt), without checking the address book at all.

    SELECT SUBSTR(LastName, 1), Count(*) FROM Customers GROUP BY SUBSTR(LastName, 1) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName, 1)

    sorry

  • Gandor (unregistered) in reply to qbolec

    [quote=qbolec]hmm actually the strpos takes (haystack, needle, offset), so chances are, that since the haystack = single letter, and offset == 1, then you always get false...[/quote] exactly... So you can rewrite function to something like return A-Z...

  • Gandor (unregistered) in reply to Xenon Xavior
    Xenon Xavior:
    toth:
    I know it's a very minor thing, but using split() for constant arrays annoys me. You only have to write it once, why not just say
    $alphabet = ['A', 'B', 'C', ..., 'Z'];
    

    ?

    Okay, I'm sure split() isn't that expensive, but it's a pet peeve.

    Or you could just break a string into its characters in the foreach loop

    no need. You could use string as array.. For example $alphabet[0] is 'A'...

  • North Shore Beach Bum (unregistered) in reply to Ryan
    Ryan:
    When you use a string as the subject of a foreach loop in PHP, it actually treats each letter as an array element. "foreach ($alphabet as $letter)" would work just fine. This is probably the best solution, assuming someone wanted to keep the rest of the horrific code.

    Spanish has "ch" as a single letter; your solution would put "Chavez" under "C" instead of "Ch"

  • (cs)

    Officially, 'ch' hasn't been a single letter in Spanish since 1997, and 'w' has been distinct from 'v' in Swedish since 2006. According to the unimpeachable source that is Wikipedia.

  • techpaul (unregistered) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    ClaudeSuck.de:
    SELECT SUBSTR(LastName), Count(*) FROM Customers GROUP BY SUBSTR(LastName) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName)

    Then loop over the resulting letters. However, in 120.000 names I would expect to see nearly all possible letters anyway. So you could just create a link for every possible letter (what about Cyrillic?), or the most likely ones (sorry Mr. Åkerfeldt), without checking the address book at all.

    SELECT SUBSTR(LastName, 1), Count(*) FROM Customers GROUP BY SUBSTR(LastName, 1) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName, 1)

    sorry

    Why do people do complicated methods just to show valid links, if it is that important either -

    1/ Create a separate table with counts for each letter (for the alphabet or lnguage order you require). This ONLY needs updating when a change to the addressbook is made and possibly rechecked once a night or week as a cron job. Then read that table to work out if your letters should be a link or not.

    2/ Alternatively just make all links, and if no records found starting at that letter, either advance to next valid letter or redisplay last 50 of previous or blank for empty database.

    A hell of a lot less hassle.

  • (cs) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    SELECT SUBSTR(LastName), Count(*) FROM Customers GROUP BY SUBSTR(LastName) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName)
    Why include the HAVING clause? It's roughly equivalent to "WHERE 1=1", except more expensive to evaluate.
  • (cs) in reply to techpaul
    techpaul:
    ClaudeSuck.de:
    ClaudeSuck.de:
    SELECT SUBSTR(LastName), Count(*) FROM Customers GROUP BY SUBSTR(LastName) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName)

    Then loop over the resulting letters. However, in 120.000 names I would expect to see nearly all possible letters anyway. So you could just create a link for every possible letter (what about Cyrillic?), or the most likely ones (sorry Mr. Åkerfeldt), without checking the address book at all.

    SELECT SUBSTR(LastName, 1), Count(*) FROM Customers GROUP BY SUBSTR(LastName, 1) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName, 1)

    sorry

    Why do people do complicated methods just to show valid links, if it is that important either -

    1/ Create a separate table with counts for each letter (for the alphabet or lnguage order you require). This ONLY needs updating when a change to the addressbook is made and possibly rechecked once a night or week as a cron job. Then read that table to work out if your letters should be a link or not.

    2/ Alternatively just make all links, and if no records found starting at that letter, either advance to next valid letter or redisplay last 50 of previous or blank for empty database.

    A hell of a lot less hassle.

    Are you suggesting that you think his result set will contain letters with no associated address book entries? Also, maintaining denormalized data could easily turn into more hassle than simply calculating it when necessary.

    BTW, if you want some insight into why people complicate things, examine your method 2. What you suggest is way more complicated than simply showing no results for letters that have no entries.

  • (cs) in reply to tehR
    tehR:
    It looks worse than it really is. What we don't know is the compiler is optimizing that loop for the six cores the server is using, so, no big deal.
    What compiler? This is PHP - it's interpreted. I doubt it would try to multithread a loop like that, anyway.
  • Gary Olson (unregistered)

    [quote]if($has_letter)/[quote]Looks like someone is working the naughty or nice list; and this is definitely naughty.

  • Oli (unregistered)

    Wtf... I can't even figure out what this is doing.

  • Anonymous (unregistered)

    Has anyone noticed the trackback spam? There's a link to a random wordpress blog.

  • Anthony (unregistered)

    So what solution would you think is more efficient? I thought maybe if it comes from a MySQL database you could use the SUBSTR() function from MySQL with DISTINCT and ORDER BY, to get a list. I'm curious if there's a better solution.

  • Dave (unregistered) in reply to Darth Paula
    Darth Paula:
    I have Åkerfeldted your Mikael. Pray I don't Åkerfeldt it further.

    仮他龪 your Åkerfeldt.

  • UK_Aspie (unregistered) in reply to frits

    I assume that was in the USA - many Americans still don't know there are other countries with other languages.

  • Matt Westwood (unregistered) in reply to UK_Aspie
    UK_Aspie:
    I assume that was in the USA - many Americans still don't know there are other countries with other languages.
    ... any more.
  • Howard Payne (unregistered) in reply to Thomas Jonathan Jackson
    Thomas Jonathan Jackson:
    frits:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."

    This is America you communist.

    Pop quiz hotshot. There is a swedish letter that needs to be added to your CMS application. Adding it will be a bitch. If you don't add it, the swedes won't extradite WikiLeaks founder Julian Assange to the US so you can like totally torture him and junk. What do you do? What do you do?

  • Banaan (unregistered)

    Well... At least is very readable code.

  • (cs)

    Apart from the general idiocy - was anyone else struck by the lack of "break;" after the letter was found?

  • Bushea (unregistered)

    A little offtopic.. Is there any reason the Google gadget is not pulling the latest topics since about a week ago?

  • pjt33 (unregistered) in reply to Rootbeer
    Rootbeer:
    Officially, 'ch' hasn't been a single letter in Spanish since 1997 <snip> According to the unimpeachable source that is Wikipedia.
    It has been collated as 'c' 'h' since 1997, but it only officially ceased to be a letter a few weeks ago.
  • (cs) in reply to Ryan
    Ryan:
    Or, you could just, you know, display all the letters and if you display an empty page because there are no people with names starting with that letter, who cares?
    A random marketing jerk thinking he's been very smart pointing this unacceptable flaw in the design. The boss listens usually more to this guy than he does listen to tech people...

    Therefore the very existence of this site.

    Addendum : graphists hate these people as much as us developers, because when the "bug" is fixed, they usually add "I don't really like the blue color of the background. Could you make it more... orange ?"

  • Anonymous (unregistered)
    cindy:
    find for all kinds of amazing watches and women handbags

    http://diaf.you.god.damn.spammer.com/

    Akismet fails yet again to stop even the most obvious of spam. But you can bet it won't fail to stop an internal link to thedailywtf.com or a useful reference to wikipedia.org. Screw you Akismet, I hate you almost as much as I hate spammers.

  • (cs) in reply to An alternate explanation
    Ryan:
    Or, you could just, you know, display all the letters and if you display an empty page because there are no people with names starting with that letter, who cares?
    Who cares ? A random marketing jerk thinking he's been very smart pointing this unacceptable flaw in the design. The boss listens usually more to this guy than he does listen to tech people...

    Therefore the very existence of this site.

    Addendum : graphists hate these people as much as us developers, because when the "bug" is fixed, they usually add "I don't really like the blue color of the background. Could you make it more... orange ?"

  • trwtf (unregistered) in reply to danixdefcon5
    danixdefcon5:
    Up to the last decade of the 20th century, sorting was a bitch in Spanish as well, because they insisted in calling "ch" a single letter, despite writing it as two separate letters. Thank god for IT, that made the RAE disavow that travesty of a "letter".

    Anybody who has trouble sorting ch as a single letter needs to sit down and have a long, hard think about what it is they're doing in this business.

  • Yankee Doodle (unregistered) in reply to Howard Payne
    Howard Payne:
    Pop quiz hotshot. There is a swedish letter that needs to be added to your CMS application. Adding it will be a bitch. If you don't add it, the swedes won't extradite WikiLeaks founder Julian Assange to the US so you can like totally torture him and junk. What do you do? What do you do?
    Swedes... swedish... that's part of Afghanistan, right?

    Anyway, we don't torture anybody. We just make them think they're drowning, that's all. Totally not torture.

  • ClaudeSuck.de (unregistered) in reply to Jaime
    Jaime:
    ClaudeSuck.de:
    SELECT SUBSTR(LastName), Count(*) FROM Customers GROUP BY SUBSTR(LastName) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName)
    Why include the HAVING clause? It's roughly equivalent to "WHERE 1=1", except more expensive to evaluate.
    The HAVING clause checks if this letter has a count bigger than zero, i.e. if this letter is not in the address book it will also not be in the resultset.
  • Simportant (unregistered)

    The real wtf is letting a sys admin near code

  • Design Pattern (unregistered) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    Jaime:
    ClaudeSuck.de:
    SELECT SUBSTR(LastName), Count(*) FROM Customers GROUP BY SUBSTR(LastName) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName)
    Why include the HAVING clause? It's roughly equivalent to "WHERE 1=1", except more expensive to evaluate.
    The HAVING clause checks if this letter has a count bigger than zero, i.e. if this letter is not in the address book it will also not be in the resultset.
    In which alternat universe are you living?

    It must be one where the SELECT clause selects data that does not exist in the database!

  • Design Pattern (unregistered) in reply to ClaudeSuck.de
    ClaudeSuck.de:
    SELECT SUBSTR(LastName, 1), Count(*) FROM Customers GROUP BY SUBSTR(LastName, 1) HAVING Count(*) > 0 ORDER BY SUBSTR(LastName, 1)

    What database is this (a substr with two arguments?)

    Also it does not meet the original requirements (be insanely stupid and filter out non-ASCII-alphabet-letters)

    Improved version, tested with Sybase and MS-SQL:

    select upper(substring(LastName, 1, 1)), count(upper(substring(LastName, 1, 1)))
    from Customers
    where charindex (upper(substring(LastName, 1, 1)), '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') % 2 = 1
    group by upper(substring(LastName, 1, 1))
    
  • Henning Makholm (unregistered) in reply to frits
    frits:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."
    Um, we don't have any such person. There's a Mikael kerfeldt, a Mikael kerfeldt, a Mikael Ã%85kerfeldt, Mikael Ã\u0083;%85kerfeldt, and Mikael ]kerfeldt. Would you like to be connected to one of those?
  • (cs) in reply to Dave
    Dave:
    Darth Paula:
    I have Åkerfeldted your Mikael. Pray I don't Åkerfeldt it further.

    仮他龪 your Åkerfeldt.

    מייַן כאַווערקראַפט איז פול ילז.

  • (cs) in reply to regeya
    regeya:
    "Hi. I can't find Mikael Åkerfeldt's name in your address book."

    Now there's a name I never expected to see on TDWTF!

    Is Opeth way bigger in Europe than they are in the States?

    I wouldn't know. I'm from the USA. They're relatively big among US metal fans as far as I can tell. I'm a big fan.

Leave a comment on “Thorough Letter Checking”

Log In or post as a guest

Replying to comment #:

« Return to Article