• (cs) in reply to Some Java Guy
    Some Java Guy:
    So the real WTF is C#.

    Is that even a real programming language?

    Wow, I can hear your fapping from here. Surely that must be hurting?

  • Franz Kafka (unregistered) in reply to AT
    AT:
    Well, no. It was actually made to provide a from-scratch, managed-code environment well-suited to Windows development. MS tried integrating Java with Windows and Sun sued to stop them. You may believe MS did this to protect its OS monopoly, but regardless of that the J/Direct technology created by Sun was much nicer to work with on Windows than JNI.

    All Sun did was hold MS to their agreement - adding native hooks to java while calling it java defeats the purpose.

  • (cs) in reply to M L
    M L:
    Codepope:
    I like the use of .ToString() rather than .toString()...

    It's subtle but full aroma code smell... :)

    That's just the subtle smell of C# and not the Java you thought you were smelling. It is normal C# code style to have capitalized method names. (Also note the foreach loop is not Java's either.)

    It's lovely to know that there's a paprika-type code smell here.

    We must all live up to really important code standards such as putting the right capital letters in the right places. I, myself, as a BrainBench-certified Spelling Nazi, regard this as a given.

    Now.

    How about the code?

    Java and C# code weenies... Pfft.

  • Ritsaert (unregistered)

    Gee, even the dates are strings...

  • (cs) in reply to Quinnum
    Quinnum:
    Wow, I can hear your fapping from here. Surely that must be hurting?
    That's gotta be the first time that a captcha has actually signed on to make a comment.

    I've never actually heard masturbation, myself. Do explain to us what it sounds like. Or indeed how it might be relevant.

  • (cs) in reply to real_aardvark
    real_aardvark:
    Quinnum:
    Wow, I can hear your fapping from here. Surely that must be hurting?
    That's gotta be the first time that a captcha has actually signed on to make a comment.

    I've never actually heard masturbation, myself. Do explain to us what it sounds like. Or indeed how it might be relevant.

    I'll remember to speak slower next time so you understand my comment.

  • ac (unregistered) in reply to smxlong
    smxlong:
    Ok, it's a little hokey, but I don't see what the problem is. If a new field is added, this code requires the addition of only a single line of code -- a new case. Each of you, ask yourselves, under your solution (whatever that might be), how many lines would YOU need to add a field? I'm not saying it can't be done some other way, but I really am not seeing a WTF here.
    A single line of code? How about the following in python:
    class LineItem:
        def __init__(self, fields):
            fieldNames = ('category', 'paymentMethod', 'transDate', 'blah')
            for i in range(len(fields)):
                setattr(self, fieldNames[i], str(fields[i]))
    
    Not that doing so is a good idea, but just to show you how it can be done if you really want it that way.

    I have seen one of my colleague coded a worse for-switch-case WTF (worse because in that case a list/array followed by a for-loop is really the no-brainer solution). I felt sad for the customer, who thought it was a big WTF also. But the customer, who was my ex-colleague, didn't request the code to be changed, because it was him who hired my colleague in the first place (another WTF) before he left and then became our customer (bigger WTF?).

  • JimM (unregistered)
    mujn:
    Even more to Raph's point, I reflected on what Street Fighter taught me, an awful lot. *snip snip snip*
    The spam... the captchas do nothing!
  • (cs) in reply to Codepope
    Codepope:
    Actually, wouldn't it be a good idea for Daily WTF to actually label code segments with what language they are meant to be rather than making the reader infer it from the text.

    No, that would take half the fun out of it.

  • (cs)
    muyknhngybf:
    If you’re in a corporation – the EVE version of guilds – this opens up the option of warfare.

    I know you're just a spammer and you should FOAD, but god damnit that it is a good quote.

    Spam boy, you just been sig'd..

  • (cs) in reply to An apprentice
    An apprentice:
    But it's so intuitive. For example you can write:
    deduction_breakfast + deduktion_lunch + deduktion_dinner
    and it will compile successfully.

    Just be glad it wasn't written by a programmer over a certain age (probably about 80) raised in the certain parts of the southern U.S. To my grandparents, lunch was called "dinner" and dinner was "supper".

    captcha: none, cos I'm registered, bitches.

  • notJoeKing (unregistered) in reply to Al
    Al:
    notJoeKing:
    C# was only created because C++ developers were too Prima Donna to switch to VB.Net...

    VB.Net is the real WTF.

    Wow. You really got me there. Your logic is just insurmountable...

    ROFL

    But seriously, what can you do in C# that you can't do in VB.Net? Abuse select-case statements by leaving out the Break;?

  • mierda (unregistered) in reply to Frodo

    mierda

  • mierda (unregistered) in reply to Frodo

    mierda

  • malditos idiotas (unregistered) in reply to mierda

    malditos idiotas de procresia ladrones de mierda

  • malditos idiotas (unregistered) in reply to mierda

    malditos idiotas de procresia ladrones de mierda

  • iogy (unregistered) in reply to Dave
    Dave:
    Anon:
    The goggles...they do nothing!

    Why do people consistently misquote that line?

    Because that version fits the ethnic stereotype's accent better.

  • gman (unregistered)

    Stupid question: given that list of objects, and the need to set those variables from those objects, and the objects being optional, what's the right way to write that?

  • JimM (unregistered) in reply to gman
    gman:
    Stupid question: given that list of objects, and the need to set those variables from those objects, and the objects being optional, what's the right way to write that?
    Hard to say, given that we don't know where the Object Array that the constructor takes in coming from, but to start with each field should be assigned to a variable of the appropriate datatype. That's kind of the point of strong datatypes. Yes, you can cast everything to a String, but then you need to know what it was to start with before you can do anything with it (other than display it in a form label, I suppose...).

    There may be a deeper WTF here with the data retrieval / storage mechanism - for some reason it seems to read a variety of values from somewhere and cast each one into an Object, before putting the Objects in an array in a specific order. That wouldbe a WTF in itself, but could be dealt with more logically by creating 28 sensibly named constants (e.g. private final int DEDUCTION_LUNCH = 13;) to index into the array, and then 28 GetItemname() methods which use the constant name as the index into the Object array, cast the Object into an appropriate type and return it (it may not be the standard in C#, but in Java it is strongly recommended that all class variables are private, and access to them in controlled by getters and setters...)

  • JimM (unregistered) in reply to gman
    gman:
    Stupid question: given that list of objects, and the need to set those variables from those objects, and the objects being optional, what's the right way to write that?
    To be fair, my previous comment didn't really answer your question. Given the prerequisites you specify above, [i]there is no "right way"[i] to write the code.

    You are ending at the wrong place. It's like asking which train to get to, say, West Pinchbeck (a small village I used to live in). I could tell you which train to get, but you'll find that when you get off it you're still five miles from your destination. The problem is you've chosen the method (train) of solving the problem without really considering the problem (getting to west Pinchbeck). In this instance, the method (assiging values to 28 String variables) is a bad way of dealing with the problem (providing access to 28 variables, of various type, which are stored in an Object array at known index values). If you are writing the wrong solution, then there cannot be a "right" way to do it.

Leave a comment on “Type Safety Considered Harmful”

Log In or post as a guest

Replying to comment #:

« Return to Article