• a care-bear (unregistered)

    care-bear obliterates the competition by care-bear-staring into frist

  • Ocson (unregistered)

    WTFCommentA

  • Chester (unregistered)

    WTFCommentB

  • highphilosopher (unregistered)

    Was this WTF generated via a WTF Generator, or did this really happen?

  • (cs)

    This is pure brilliant because...uh, never mind.

  • (cs)

    Gotta be fun to try this with unicode.

  • Jan (unregistered)

    This is best practice on embedded devices!

  • Barry (unregistered) in reply to Jan
    Jan:
    This is best practice on embedded devices!

    I would take a photo of the alphabet on a wooden table...

  • Befton John (unregistered)

    This would've been even more brillant if written in VB.

  • Knux2 (unregistered)

    (Java)

    System.out.println(ClassTypeW + ClassTypeO + ClassTypeW 
      + ", " + ClassTypei + ClassTypet + " " + ClassTypes
      + ClassTypeu + ClassTyper + ClassTypee + " " + ClassTypet
      + ClassTypea + ClassTypek + ClassTypee + ClassTypes + " "
      + ClassTypea + " " + ClassTypel + ClassTypeo + ClassTypen
      + ClassTypeg + " " + ClassTypet + ClassTypei + ClassTypem
      + ClassTypee + " " + ClassTypet + ClassTypeo + " "
      + ClassTypet + ClassTypey + ClassTypep + ClassTypee + " "
      + ClassTypea + " " + ClassTypes + ClassTypee + ClassTypen
      + ClassTypet + ClassTypee + ClassTypen + ClassTypec
      + ClassTypee + " " + ClassTypet + ClassTypeh + ClassTypei
      + ClassTypes + " " + ClassTypew + ClassTypea + ClassTypey
      + "!");
    
  • Elmo (unregistered)

    This is very handy.

    Just in case the alphabet changes, in that case you are prepared!

  • pointyhairedpeon (unregistered)

    That's actually pretty clever, in this way one can use inheritance to, I don't know, change the string associated to each letter. But it'd be better to dynamically generate this code through a SQL query, and embed the query into a PHP script. Then I'd write a small VB script piloting the cursor and the keyboard buffer in order to open Access, write the SQL query and launch it automatically.

    CAPTCHA: dolor - how oddly appropriate.

  • (cs)

    This solution is clearly not correct. There's no support for lower case letters...

  • ClutchDude (unregistered)

    Wait....

    Let me get this straight.

    Everything in string the class is private and there are no other classes or methods?

    I'm going to say it's the lack of sleep, but is there a point to this class if it's all private w/o getters?

  • (cs)

    This is ridiculous. It's utterly useless; how do you do lowercase letters? And punctuation?

  • grizz (unregistered) in reply to pointyhairedpeon
    pointyhairedpeon:
    That's actually pretty clever, in this way one can use inheritance to, I don't know, change the string associated to each letter. But it'd be better to dynamically generate this code through a SQL query, and embed the query into a PHP script. Then I'd write a small VB script piloting the cursor and the keyboard buffer in order to open Access, write the SQL query and launch it automatically.

    -1: Where's the XML?

  • Vladimir (unregistered)

    Генерация кода может быть эффективным инструментом для сильно вводе пользовательских доменов, если данный домен ограничена определенным набором ценностей. Приемлемые примеров можно назвать имена цветов, статусов, и штаты США, среди ряда других.

    В некоторых случаях это полностью избыточными для этого, например, если вы сильно набрав алфавиту:

    ClassTypeLetters общественного класса ( частных пд ClassTypeA = ""; частных пд ClassTypeB = "B"; частных пд ClassTypeC = "C"; частных строку сопзЬ ClassTypeD = "D"; частных ClassTypeE строку сопзЬ = "E"; частных пд ClassTypeF = "F"; частных ClassTypeG строку сопзЬ = "G"; / / H-W ... частных пд ClassTypeX = "X"; частных ClassTypeY строку сопзЬ = "Y"; частных пд ClassTypeZ = "Z"; )

  • Mister Zimbu (unregistered) in reply to toth
    toth:
    This is ridiculous. It's utterly useless; how do you do lowercase letters? And punctuation?

    ClassTypeLetters.CreateLetterTransformationFactory<ClassTypeA>(this).TransformLetter(LetterTransformationFactoryTypes.LowerCaseInvariant);

  • KeithJM (unregistered)
    I'm going to say it's the lack of sleep, but is there a point to this class if it's all private w/o getters?

    Are you implying that there WOULD be a point to this class if it was public and had getters?

  • (cs) in reply to Ocson

    private const string ClassTypeComment = "Comment";

  • James Michael Hare (unregistered)

    Hah, love it. Actually I remember some legacy code I worked on right out of college that had the following C #defines:

    #define ZERO 0 #define ONE 1

    Glad we're isolated in case zero or one change their numeric values...

  • (cs)

    TRWTF is that the strings aren't marked static and final.
    (Yes.... that will do.)

  • SR (unregistered) in reply to Knux2
    Knux2:
    (Java)
    System.out.println(ClassTypeW + ClassTypeO + ClassTypeW 
      + ", " + ClassTypei + ClassTypet + " " + ClassTypes
      + ClassTypeu + ClassTyper + ClassTypee + " " + ClassTypet
      + ClassTypea + ClassTypek + ClassTypee + ClassTypes + " "
      + ClassTypea + " " + ClassTypel + ClassTypeo + ClassTypen
      + ClassTypeg + " " + ClassTypet + ClassTypei + ClassTypem
      + ClassTypee + " " + ClassTypet + ClassTypeo + " "
      + ClassTypet + ClassTypey + ClassTypep + ClassTypee + " "
      + ClassTypea + " " + ClassTypes + ClassTypee + ClassTypen
      + ClassTypet + ClassTypee + ClassTypen + ClassTypec
      + ClassTypee + " " + ClassTypet + ClassTypeh + ClassTypei
      + ClassTypes + " " + ClassTypew + ClassTypea + ClassTypey
      + "!");
    

    Code review: add classTypeComma, classTypeSpace and classTypeExclamationMark and you're onto a winner (a space and 2 punctuation marks ought to be enough for anyone).

  • Steven (unregistered)

    #include <stdio.h>

    #define LETTER_TABLE
    X(A, "A")
    X(B, "B")
    X(C, "C")
    X(D, "D")
    X(E, "E")
    X(F, "F")
    X(G, "G")
    X(X, "X")
    X(Y, "Y")
    X(Z, "Z")

    #define X(a, b) a, enum LETTER { LETTER_TABLE }; #undef X

    #define X(a, b) b, char *letter_name[] = { LETTER_TABLE }; #undef X

    int main() { enum LETTER x = A; printf("x=%s\n", letter_name[x]); return 0; }

  • pointyhairedpeon (unregistered) in reply to grizz

    Bah, XML is for sissies: much better to use RSS for adding comments to the sourcecode, giving for each line of the code a different URL containing the documentation associated to it.

  • @SuppressWarnings (unregistered) in reply to @Deprecated

    What language has both const and final keywords?

  • (cs) in reply to Vladimir
    Vladimir:
    Генерация кода может быть эффективным инструментом для сильно вводе пользовательских доменов, если данный домен ограничена определенным набором ценностей. Приемлемые примеров можно назвать имена цветов, статусов, и штаты США, среди ряда других.

    В некоторых случаях это полностью избыточными для этого, например, если вы сильно набрав алфавиту:

    ClassTypeLetters общественного класса ( частных пд ClassTypeA = ""; частных пд ClassTypeB = "B"; частных пд ClassTypeC = "C"; частных строку сопзЬ ClassTypeD = "D"; частных ClassTypeE строку сопзЬ = "E"; частных пд ClassTypeF = "F"; частных ClassTypeG строку сопзЬ = "G"; / / H-W ... частных пд ClassTypeX = "X"; частных ClassTypeY строку сопзЬ = "Y"; частных пд ClassTypeZ = "Z"; )

    I couldn't said it better.

  • (cs) in reply to pointyhairedpeon
    pointyhairedpeon:
    Bah, XML is for sissies: much better to use RSS for adding comments to the sourcecode, giving for each line of the code a different URL containing the documentation associated to it.

    Actually, with the right approach, this could be a great idea.

  • Keith Brawner (unregistered) in reply to ubersoldat

    Doxygen?

  • (cs) in reply to @SuppressWarnings
    @SuppressWarnings:
    What language has both const and final keywords?

    Oh, sure, get all technical on me...

    All I can say is someone mentioned Java and then I blanked on the const....

  • (cs) in reply to apaq11
    apaq11:
    This solution is clearly not correct. There's no support for lower case letters...

    Duh, just call .ToLower() to get lowercase. There's no need to reimplement functionality that's already provided.

  • Jim (unregistered) in reply to frits
    frits:
    apaq11:
    This solution is clearly not correct. There's no support for lower case letters...

    Duh, just call .ToLower() to get lowercase. There's no need to reimplement functionality that's already provided.

    You genius. How do comments get 'featured'?

  • Mr Smiþ (unregistered) in reply to Elmo
    Elmo:
    This is very handy.

    Just in case the alphabet changes, in that case you are prepared!

    Þat is a good point. Just add on:

    private const string ClassTypeÞ = "Þ";

    and þe code will be ready!

    (I sure hope the Daily WTF comment software accepts thorns or this post will look stupid. Well, more stupid than it is inherently.)

  • (cs) in reply to Mister Zimbu
    Mister Zimbu:
    toth:
    This is ridiculous. It's utterly useless; how do you do lowercase letters? And punctuation?

    ClassTypeLetters.CreateLetterTransformationFactory<ClassTypeA>(this).TransformLetter(LetterTransformationFactoryTypes.LowerCaseInvariant);

    I just threw up a little in my mouth.

  • Buddy (unregistered)

    It could have a purpose as part of a character classification algorithm or converting UNICODE/LATIN-1 to ASCII 7-bit say in e-mail or news readers.

    E.g.

    A a À Á Â Ã Ä Å Æ à á â ã ä å æ => ClassTypeA

    Thinking really way out there, ClassType* could be redefined later on as Morse code or something and then it would be almost a logical way to do things.

    ClassTypeA = DOT DASH; ClassTypeB = DASH DOT DOT DOT; ...

    During development would set it first as "A", "B", etc. to make it easier.

  • -anon for this (unregistered)

    Off-topic, I've come across code where the multiplication factors for k (as in kilo), c (as in centi), m (as in milli), ..., were defined in an XML file. This file was then parsed by the framework, whence a factory pattern was used to provide the required real multiplying factor to the end application.

    This might have been an acceptable solution had the XML file been stored in a database table [n.b. the previous sentence is intended to be an ironical remark]. However, the XML was instead stored in the flash RAM of the embedded device, making it way too "hands-on" to be "enterprisey".

    Needless to say, this "solution" was soonish returned to the designers for re-consideration.

  • Kempeth (unregistered) in reply to grizz
    grizz:
    -1: Where's the XML?
    I totally agree! As it is you have to change the source code every time the alphabet changes.
  • (cs) in reply to @SuppressWarnings
    @SuppressWarnings:
    What language has both const and final keywords?
    Java does.
  • Anon (unregistered)

    I've seen something similar but with numeric constants. It was because corporate policy involved running a code style checker, and it complained about "magic numbers." Which really translated to "any numeric constant that was greater than 3."

    Solution?

    public class Numbers { public static int NUMBER_4 = 4; public static int NUMBER_5 = 5; .... }

  • Salvatore (unregistered) in reply to James Michael Hare

    Lucky you it was "college code"

    I saw the following C defines in code at WORK, that runs on a embedded system which manage the communication module of a TRAIN.

    #define THOUSAND 1000 #define THIRTY 30

    and a few others.

    I'm not kidding.

  • Salvatore (unregistered) in reply to James Michael Hare
    James Michael Hare:
    Hah, love it. Actually I remember some legacy code I worked on right out of college that had the following C #defines:

    #define ZERO 0 #define ONE 1

    Glad we're isolated in case zero or one change their numeric values...

    Lucky you it was "college code"

    I saw the following C defines in code at WORK, that runs on a embedded system which manage the communication module of a TRAIN.

    #define THOUSAND 1000 #define THIRTY 30

    and a few others.

    I'm not kidding.

  • (cs)

    Someone please explain to me how "Code generation" has anything to do with this particular WTF.

  • Hatterson (unregistered) in reply to James Michael Hare
    James Michael Hare:
    Hah, love it. Actually I remember some legacy code I worked on right out of college that had the following C #defines:

    #define ZERO 0 #define ONE 1

    Glad we're isolated in case zero or one change their numeric values...

    Well it could be worse.

    #define ZERO 1 #define ONE 0

  • (cs) in reply to Jim
    Jim:
    frits:
    apaq11:
    This solution is clearly not correct. There's no support for lower case letters...

    Duh, just call .ToLower() to get lowercase. There's no need to reimplement functionality that's already provided.

    You genius. How do comments get 'featured'?

    • ClassType1
  • AnOldRelic (unregistered) in reply to Buddy
    Buddy:
    Thinking really way out there, ClassType* could be redefined later on as Morse code or something and then it would be almost a logical way to do things.

    ClassTypeA = DOT DASH; ClassTypeB = DASH DOT DOT DOT; ...

    This kind of thing needs to broadcast DOT DOT DOT DASH DASH DASH DOT DOT DOT.
  • (cs) in reply to ubersoldat
    ubersoldat:
    Vladimir:
    Генерация кода может быть эффективным инструментом для сильно вводе пользовательских доменов, если данный домен ограничена определенным набором ценностей. Приемлемые примеров можно назвать имена цветов, статусов, и штаты США, среди ряда других.

    В некоторых случаях это полностью избыточными для этого, например, если вы сильно набрав алфавиту:

    ClassTypeLetters общественного класса ( частных пд ClassTypeA = ""; частных пд ClassTypeB = "B"; частных пд ClassTypeC = "C"; частных строку сопзЬ ClassTypeD = "D"; частных ClassTypeE строку сопзЬ = "E"; частных пд ClassTypeF = "F"; частных ClassTypeG строку сопзЬ = "G"; / / H-W ... частных пд ClassTypeX = "X"; частных ClassTypeY строку сопзЬ = "Y"; частных пд ClassTypeZ = "Z"; )

    I couldn't said it better.

    Agreed. You obviously couldn't do that...

  • tragomaskhalos (unregistered) in reply to Salvatore
    Salvatore:
    James Michael Hare:
    Hah, love it. Actually I remember some legacy code I worked on right out of college that had the following C #defines:

    #define ZERO 0 #define ONE 1

    Glad we're isolated in case zero or one change their numeric values...

    Lucky you it was "college code"

    I saw the following C defines in code at WORK, that runs on a embedded system which manage the communication module of a TRAIN.

    #define THOUSAND 1000 #define THIRTY 30

    and a few others.

    I'm not kidding.

    This sort of thing is not uncommon. The usual culprit is a "no magic numbers" clause in a coding standard (along with an implicit "no common sense either") of course ....

  • Anonymous Coward (unregistered) in reply to Anon
    Anon:
    I've seen something similar but with numeric constants. It was because corporate policy involved running a code style checker, and it complained about "magic numbers." Which really translated to "any numeric constant that was greater than 3."

    Solution?

    public class Numbers { public static int NUMBER_4 = 4; public static int NUMBER_5 = 5; .... }

    Obviously you were the person they needed that code style checker for. Why 4? 5? 7?

    When you have a loop stating

    for (i=0;i<7;i++) { /* do something */ }

    you'll be guessing what 7 means and why the number 7 was used. Whereas if the same code would (depending on the language you use) would say something like

    const DAYSPERWEEK=7;

    then the loop would be

    for (i=0; i<DAYSPERWEEK; i++) { /* do something */ }

    ...and this would make it instantly clear that the loop iterates each weekday (rather than the seven dwarfs in "Snow White").

    Note also that your NUMBER_4, NUMBER_5, NUMBER_6 etc. do not add anything useful to the readability of the code.

  • getofmymetriclawn (unregistered) in reply to Buddy
    Buddy:
    It could have a purpose as part of a character classification algorithm or converting UNICODE/LATIN-1 to ASCII 7-bit say in e-mail or news readers.

    E.g.

    A a À Á Â Ã Ä Å Æ à á â ã ä å æ => ClassTypeA

    Please, avoid any job that has a remote connection to localization or international communications. This algorithm is already used much to often. Under no conceiveable circumstances is "A" a good representation for an "Ä" or "Æ". If you really have to use 7-bit ASCII, Ä and Æ can be represented as AE. Not that there is a good reason for using anything other than a proper unicode encoding like UTF-8 anyways.

  • SR (unregistered)

    I'm all for strong typing. I make good use of YesNoUnknown (though had I rolled my own it would have been YesNoUnknownFileNotFound)

Leave a comment on “ArticleTypeCodeSOD”

Log In or post as a guest

Replying to comment #:

« Return to Article