• boo (unregistered)

    For Christ's sake people, the code is fine, it's the pure and simply fact that the submitor sent a hard copy of the email and not just forward/submit it.

    captcha: craaazy

    How apt..

  • Someone (unregistered) in reply to RON
    RON:
    Someone:
    RON:
    He's not converting a control to a number, which is impossible to do.

    The function takes a Control as input. It returns a double as output. The output is a different representation of the input. How is that not converting a Control to a number?

    So any function that takes one piece of input and returns another is automatically considered a conversion?

    Not what I said. Save the straw men for the crows, please.

  • (cs)

    To those that have responded:

    Layout by hand: No I don't just place a control on a form and let it sit, I do have to code all the calculations so it sizes with the form. Yes I'm using MS products here. The only layout help you get is with anchors.

    Grid Layout: Sounds good, I wish I had that available to me.

  • rgz (unregistered) in reply to boo
    boo:
    For Christ's sake people, the code is fine, it's the pure and simply fact that the submitor sent a hard copy of the email and not just forward/submit it.

    captcha: craaazy

    How apt..

    That's what I though but he said 0 is a valid input which means ANYTHING is a valid input, if the parser can't handle it 0 is returned, "arse" is valid, "" is valid "1/7" is valid, they all return 0, now thats what i call some broken code!

  • Sazoo (unregistered) in reply to morry

    I think you might have - never mind - here's one of mine "."

    (nostalgic wooden table moment - sigh!)

  • (cs)

    This code is definitely not fine. It's not nearly as bad as most of the other code posted on this site, but it's full of those small WTFs that tend to accrue in a project run by incompetents.

    • When a maintenance programmer examines the code for the first time, she will consider these helper functions as black boxes that simply perform the work indicated in their name/signature. This is why proper naming of functions is so important, and "convertControl2Double(Control)" is definitely a WTF.

    • Writing to a logger in a conversion function. Come on now.

    • Returning a sensible-looking, valid value upon failure. Sure this probably works in some cases, but this looks like it's meant to be a general-use helper function. Just let the caller deal with the damn exception.

    There's no real reason to use this over the TryParse() methods, which incidentally will also assign 0 to the value on failure (though failure will be properly indicated). Even if it was .NET 1, the double type still had TryParse.

    The only functional difference between:

    double val = convertControl2Double(textBox);

    and

    double val; double.TryParse(textBox.Text, out val);

    ...is the lack of the retarded logging behaviour.

  • (cs) in reply to igitur
    igitur:
    I don't think the parser is clever enough to recognise the spaces as 1000s separator.

    It is.

    http://msdn2.microsoft.com/en-us/library/system.globalization.numberstyles.aspx

  • boo (unregistered) in reply to bobday
    bobday:
    This code is definitely *not* fine. It's not nearly as bad as most of the other code posted on this site, but it's full of those small WTFs that tend to accrue in a project run by incompetents.
    • When a maintenance programmer examines the code for the first time, she will consider these helper functions as black boxes that simply perform the work indicated in their name/signature. This is why proper naming of functions is so important, and "convertControl2Double(Control)" is definitely a WTF.

    • Writing to a logger in a conversion function. Come on now.

    • Returning a sensible-looking, valid value upon failure. Sure this probably works in some cases, but this looks like it's meant to be a general-use helper function. Just let the caller deal with the damn exception.

    There's no real reason to use this over the TryParse() methods, which incidentally will also assign 0 to the value on failure (though failure will be properly indicated). Even if it was .NET 1, the double type still had TryParse.

    The only functional difference between:

    double val = convertControl2Double(textBox);

    and

    double val; double.TryParse(textBox.Text, out val);

    ...is the lack of the retarded logging behaviour.

    You call that a "wtf"?

    Christ..

    double val = convertControl2Double(textBox);
    if (val == 0) { /* there is an unacceptable value.. */}

    This is why most WTF's suck, absolutely 0 context is provided with i and just about everything is from the domain model; where the implementation will more than likely be unique. Either that or they are from someone's first "real" (read: more advanced than 'Hello world!') application.

    However, I do agree the logging should not be in there - but that's hardly WTF worthy.

    CAPTCHA: onomatopoeia

  • david (unregistered)

    At several of my client sites, it is impossible to send code through the email system.

    At some of my client sites, you don't even get an exception or warning when you try. Anything that looks like code is treated like spam.

  • Waffles (unregistered)

    The real WTF is that crazy indentation.

  • VolodyA! V A (unregistered)

    I've not read all the comments yet, so i don't know if some (highly Brilliant) person has already mentioned this but.

    You can convert from hours to millimeters. One misunderstood thing about Einstein's theory of relativity is that c is not speed of light, but rather a constant which is equal to speed of light in a vacuum (more or less). The units m/s represent the proportion rather than speed.

    This is due to the fact that Einstein has envisioned the universe as having 4 dimentions: x, y, z, t. So 300 000 000 meters to the left equals 300 000 000 meters forward equals to 300 000 000 meters above equals to 1 second in the future.

Leave a comment on “Converting Apples to Oranges”

Log In or post as a guest

Replying to comment #:

« Return to Article