• Hanzito (unregistered)

    I'm not certain that I've seen this particular abuse of ternaries before.

    I have. In the output of JS obfuscators.

  • LZ79LRU (unregistered) in reply to Hanzito

    So maybe this is code that was copy pasted from reverse engineered obfuscated source by someone who couldn't figure out that the source was obfuscated?

  • NoLand (unregistered)

    Well, that should have been void(0), instead of null! :-)

  • (nodebb)

    C ternary abuse:

    if ( some_condition ) /* not important */
        some_other_condition ? some_variable = some_expression : 0;
    else
        something_for_when_some_condition_is_false();
    

    I think someone was allergic to braces, so terned the inner if() into a turnary.

    And I'm pretty sure I've seen this one somewhere:

    (some_condition ? one_function : another_function)(arg,u,ments);
    
  • Sauron (unregistered)

    Of course, there is also validation in the back-end of the the web app, right? Right?

  • String Joiner (unregistered)

    No comment on how they use [" A", " B", " C"].toString().trim() instead of the simpler ["A", "B", "C"].join(", ") where you don't need to remember to put a space in front of every error message?

  • NoLand (unregistered)

    No comment on how they use [" A", " B", " C"].toString().trim()…?

    What about [" A", " B", " C"].toString().substring(1) ? :-)

  • LZ79LRU (unregistered)

    Validation is not in vogue any more. These days you have to allow all inputs, no matter how malformed, malicious and/or wrong and provide code in the backend to hold their hand and ensure they work no matter what. After all, if the input identifies as correct you aren't allowed to say otherwise.

  • Maia Everett (github)

    TRWTF is using the function keyword and then assigning the function to a variable.

    Personally, I prefer the function name() style, but if you're going to assign your function to a variable, at least make it a lambda.

  • Maia Everett (github) in reply to LZ79LRU

    Take your shallow trolling elsewhere.

  • Jonathan (unregistered) in reply to Maia Everett

    It is really tedious, isn't it?

  • (nodebb)

    I find validation code to be tedious, verbose, and chock-full of irritating special cases that the PMs/designers/whoevers/possibly-me never describe in the least. And then we get into the silliness that is "the API's error messages are extremely specific to the data structure the API deals with, and which the UI simplifies and hides as much as possible in the name of user-friendliness." You end up either displaying semi-irrelevant messages to the user, duplicating the validation logic in the client so you can generate a better message, or doing some kind of string-matching/regexing against the API errors to figure out when to use your better UI messages. (The best answer, returning error codes in addition to messages, so the UI can do a guaranteed-accurate lookup against a user-friendly error message, doesn't crop up terribly often at my workplace.)

    Alas, validation code is quite necessary.

  • (nodebb)

    I wonder if FluentValidation actually works with WebAssembly. Gotta check the next time I'm playing around with Blazor.

  • (nodebb) in reply to Sauron

    Backend validation is a must, frontend validation is a nice to have feature. Basically I comes down to how much the UX designer gets paid so he can slap the Hippos.

  • Jeremy (unregistered)

    On the bright side, these changes may have led to solving all the bugs. No more incoming bugreports on the report an issue form

  • LZ79LRU (unregistered) in reply to Maia Everett

    If only. Or have you newer had managers ask you: "Why do you need validation? It makes users upset. Can't you just fix the input when you get it." Don't tell me you have not?

  • WTFGuy (unregistered)

    Of course the "security" folks get their hand in. The ONLY acceptable error message to an end user must say "Something is wrong". Anything else provides valuable intel to teh ev1l haxxors and must be avoided. And this is true for both front- and back-end validation.

    Modern webdev is a WTF from one end to the other.

  • (nodebb) in reply to WTFGuy

    The ONLY acceptable error message to an end user must say "Something is wrong".

    Validation and error messages are very different things, or at least they should be. For error messages, if you are giving them the the end user and expecting the end user to transport the error message to support, then you are doing it wrong. With very little other than the answers to "Who are you?" and "What were you doing?" and "About when?", a support team should be able to find the error message directly. If they can't, then you are complaining about a problem that is your responsibility to solve, not someone else's.

Leave a comment on “Terned Off Validations”

Log In or post as a guest

Replying to comment #:

« Return to Article