• (nodebb)

    For example, let's say you saw a method called handleRSAPrivateKeyGeneration. You'd likely assume that it generates an RSA private key.

    No, I wouldn't, actually. I'd assume that it's a callback that handles (the result of) the generation of the key, so we pass it as a callback (mechanism depending on the language) to some generator function.

  • 516052 (unregistered) in reply to Steve_The_Cynic

    Same here. If I wanted a key generated I'd expect something like GenerateRSAPrivateKey or RSAPrivateKeyGenerator.Generate or PrivateKeyGenerator.GenerateRSA etc.

  • Conradus (unregistered)

    I am dead certain that, when originally written, the function generated only RSA keys. Then somebody, for the exact reasons you mentioned, decided it needed to give the user a choice of algorithms. "Add in a parameter where you specify the algorithm. No, don't change the name, it'd be too much trouble tracking down everywhere it's referred to."

  • (nodebb) in reply to Steve_The_Cynic

    It would depend on what class/file it's in. If it's in a class named something like PrivateKeyGenerator, sure, you would probably expect it to be called after the key is generated. If it's in a class of HTTP request handlers, then you would expect it to be the method that's called when the user sends a RSAPrivateKeyGeneration request, which I would guess is a request to generate a key (though as mentioned, something like GenerateRSAPrivateKey would be a better name).

  • Brian (unregistered)

    So the lesson here: avoid the generic "handle" in your method names, and pick a more descriptive verb. How is your method handling the thing?

  • Jaloopa (unregistered) in reply to Brian

    I make sure as many of my methods as possible are named HandleThing. That way, if the handling behaviour or thing type change I don't need to update the method name. This is what is known as self documenting code

  • DMLou (unregistered)

    Honestly, I think the issue here is slightly different than what Remy suggests. Still not great, and perhaps I'm being a bit pedantic here. However, I think that in a lot of minds, "RSA key" has become a generic trademark for any sort of public/private key, similar to Kleenex for facial tissue, Jell-o for flavored gelatin, etc., and I think that's what's going on here. Not sure if it makes it slightly less of a WTF or not, though.

  • Argle (unregistered)

    What about get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function.

  • (nodebb) in reply to DMLou

    Kleenex for facial tissue, Jell-o for flavored gelatin

    It's weird, because those are both thoroughly American cultural references, and yet my British "raised in" makes me reject "Jell-o" as a genericised trademark, while totally accepting "Kleenex", although I wouldn't include the word "facial" in my definition.

    Well, anyway, as I said, it's weird.

  • (nodebb) in reply to Argle

    because perimeters are shapes, not numbers.

  • xtal256 (unregistered) in reply to Brian

    Yes, same goes for "util" and "helper".

  • (nodebb)

    Given the 'value = "algorithm", defaultValue = "EC"', my guess is that this RSA-key-generation function is generating an ECDSA key by default.

    My follow-on guess, given the confusion shown in just this one line of code, is that the rest of the inevitably homebrew crypto operations they'll be using are no more secure. ECDSA use in particular is extremely easy to get wrong.

  • MaxiTB (unregistered)

    So it's a factory method not named create?

    That's a rare sight, so my guess is that it once was some sort of mutator and the refactoring didn't include the name...

  • (nodebb)

    What about get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function.

    needsMoreCamelCase.

  • Richard Nuttall (unregistered)

    OUR JOURNEY TO A LIFE CHANGING LOTTERY WIN: My name is Richard Nuttall, my wife Debbie Nuttall and I are both 54 years old. WE ARE GLAD TO ANNOUNCE TO THE WORLD THAT WE WON £61,708,321 EUROMILLIONS JACKPOT PRIZE, with the number a lottery spell caster called Lord Bubuza gave us after casting his lottery spell. This man is a great seer and he is like a God on Earth that has turned our financial status for better. He was recommended to us by a friend in my office who he helped win the lottery, and as a couple, we discussed and decided to give his spell a try. We provided his requirement to cast the lottery spell and we are £61M richer today. We have made a vow to ourselves that we will keep testifying about him. We were sceptical at first, but no protection is risky, so we tried it and we are financially stable now. Join us to appreciate this genius. Do you want to win like us? Do you need your Ex back? Contact lord Bubuza because he is a miracle worker. His email: [email protected] / WhatsApp: +1 (365) 808 5313

  • (nodebb)

    and returns a string because the result is displayed in a web page.

    And that's not considered a WTF? A private key is transmitted across the internet and displayed on a web page?

Leave a comment on “A Specific Key”

Log In or post as a guest

Replying to comment #:

« Return to Article