• Registered (unregistered)

    Not great code, but not too damaging to have an exception unless it is invoked millions of times in a loop.

    public static bool IsFrist(string theValue) { try { Convert.ToOrdinal(theValue); return true; } catch { return false; } }

  • (nodebb)

    Too bad double.TryParse() is around for 25 years since .net BETA.

    Feels to me like yet another RTFM situation, most likely from someone coming from Java since this person doesn't even know the basic value types of .net - something most C# devs learn like on the first day - and therefore used such a weird name for that useless method.

  • (nodebb) in reply to Registered

    What's Convert.ToOrdinal() ?

    That method never existed on the Convert class of .net.

    And the correct answer is as stated in the article: https://learn.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-9.0

  • Richard Brantley (unregistered)

    "...pedantry is the root of clarity"

    A large portion of my career has just been vindicated! :)

  • Toasty (unregistered)

    Telling that simple verification functions like this should be built into .net without all the intellectual drama devs inject into their code. We've got 170IQ devs who write code like function()=>Foo.New(a => ^Bar(1).First().Flarg(a.Color) (goes on for another 256 characters) ...then Dev:"Look at this...I turn the label Blue!". Me: "Why not just turn the label blue? Wouldn't that be simple?" Dev: "Pffft...simple is relative....look at this code!!!"

  • Argle (unregistered) in reply to Registered

    I got the joke even if MaxiTB didn't.

  • (nodebb) in reply to Argle

    So did I, but, ToOrdinal() will also return true for secnod and thrid.

    Addendum 2025-05-12 10:18: and FileNotFound for brillant.

    Addendum 2025-05-12 10:19: s/ToOrdinal/isFrist/

    ToOrdinal() won't throw an exception for the other cases is what I meant to say.

  • (nodebb) in reply to Argle

    Enlighten me :-)

  • Klimax (unregistered) in reply to MaxiTB

    I'd think IsFrist would be dead give away...

  • CmdrShepard (unregistered)

    You guys don't understand, this is simply exceptional programming.

    /s

  • LZ79LRU (unregistered) in reply to Registered

    They all say that until you have to debug why a function call is timing and locking up a web server out only to discover someone wrote code similar to this inside a double nested loop that does in fact get called millions of times AND has millions of lines to loop through.

  • Patrick (unregistered)

    The name might be wrong, but have some sympathy, since naming things, invalidating cache and off-by-one errors are the two hardest problems to solve in programming

  • Tinkle (unregistered)

    To be fair (or pedantic, your pick,) C# should share some of the blame for this WTF, as decimal is a bad name for a numeric type, unless it can store any decimal value - which it cannot.

  • (nodebb) in reply to Tinkle

    By that logic integer is a bad name because it can't store any integer value and male connector is a bad name because it could be a trans-gender female connector ;-).

    Lament natural language terms have never anything to do with technical definitions of terms; it can't because natural languages are by definition as vague as possible to allow for less social friction during conversations.

  • no (unregistered) in reply to MaxiTB

    when i am speaking to someone who will understand what i mean, i actually prefer using "top" and "bottom" for connectors instead of "male" and "female" for this exact reason

Leave a comment on “Would a Function by Any Other Name Still be WTF?”

Log In or post as a guest

Replying to comment #:

« Return to Article