• Ouatte & Veure (unregistered)

    Thanks for "readability". Ouch.

  • my name is missing (unregistered)

    One good tern deserves another. Actually APL is easier to read then that mess.

  • Little Bobby Tables (unregistered) in reply to my name is missing

    *than

  • Andy Kosrov (unregistered)

    Ternaries are no worse than if statements, and just like them, the only thing that makes them readable or not is how they're formatted.

  • that other guy (unregistered) in reply to Little Bobby Tables

    Maybe he meant that APL was easier to read, followed by that mess... ¯_(ツ)_/¯

  • bvs23bkv33 (unregistered)

    We had two crutches, 75 reinvented wheels, five bicycles, a whole galaxy of rakes... Also, a two dozen ternaries. Not that we needed all that for the project, but once you get into enterprise coding, the tendency is to push it as far as you can.

  • Dude (unregistered)

    At least they used parenthesis. They help a (very) little.

  • Andrew (unregistered)

    The easy reader version is not readable.

  • Ross Presser (google) in reply to that other guy

    I think you dropped this: \

  • Reginald P. Smithington (unregistered)

    There is a season, tern, tern, tern.

  • SG (unregistered)

    I'm working with TFS XAML Build definition. I WISH, had a source code like this! The [censored] drag&drop "even idiots can do this" definition leads to a unreadable mess. No chance to get it clearer with rearrangement - and the XML source is much worse. So - this is not as worse it can be.

  • dpm (unregistered) in reply to SG

    I'm working with TFS [...]

    Condolences.

  • Geoff (unregistered)

    Remy we get a ternary hurt you sometime. Its okay man we know they can abused don't need every other codsod to be on the subject. Have drink, maybe take a vacation and move on.

  • robby the robot (unregistered)

    So the WTF is someone who can't face changing code?

  • Barf4Eva (unregistered)

    I bet this looks just as lovely with if-else

  • snoofle (unregistered)

    On very rare occasions, I've had to work with stuff like that, but did not have the luxury of being able to reformat the code.

    Once I spent the time reverse engineering it, I would put the pseudo code of the formatted version in a comment just above it. Subsequent developers didn't always keep it updated, but for the most part, it helped down the road when you inevitably had to revisit that block of code.

  • Appalled (unregistered)

    There's only one thing worse than Ternary's, NESTED Ternary's. Welcome to our "GRAND PRIZE WINNER TODAY!!!!!!" If this landed in my lap to maintain, I'd have no choice but to decompose it into If and/or Case. This would suck as there's no way to parallel test all the use cases. So I'd have to invite at least 2 peers to verify my decomposition. Then if it later turned out that we all missed something, at least it would now be maintainable.

  • (nodebb)

    I have a translation matrix using cascading switch statements. It's like this, but without ternaries. Only marginally more readable though.

  • (nodebb) in reply to dpm

    TFS has come a LONG ways from where it was, and XAML builds are deprecated now - preferring to use the cleaner and more standard YAML syntax for build definitions. They are even moving toward storing the YAML definitions in your Git repository now (or TFVC if you are using that instead of Git).

    The newest version is always the cloud version: Look at Azure DevOps. Next year, the new version of TFS will also make the jump and be called Azure DevOps Server.

  • sizer99 (google)

    This is what almost all perl code looks like to me. Except with more regexps to make things more 'readable'.

  • someone (unregistered)

    What language is this?

  • (nodebb)

    Terns out Remy has no end of these.

    And are those conditionals being used to generate code that includes more conditionals?

    Yes, I'm calling them "conditionals", not "ternaries". Nyaaaa.

  • I dunno LOL ¯\(°_o)/¯ (unregistered) in reply to someone

    pig Klingon?

  • lurker (unregistered) in reply to bvs23bkv33

    We can't stop here! This is "if this then that" country!

  • siciac (unregistered) in reply to Andy Kosrov

    the only thing that makes them readable or not is how they're formatted.

    Hmm, so if my if else is formatted like so...

    if(condition) {
        then_block;
    } else {
        else_block;
    }
    

    I could format a ternary similarly:

    (condition) ? (
        then_block
    ) : (
        else_block
    )
    

    I see your point, but I think you're wrong because in practice, a ternary isn't by itself. It's generally an argument to a function call, or part of the right-hand side of an assignment, or could even be in an array index expression.

    The reason if/else syntax works is because it's working in the control flow, which is a syntax that is designed to help a reader break things into parts. And if/else construct has one place it can be: it's a statement within a block. The only things before or after it are other statements, or braces.

    The expression syntax is designed to be tersed and orthogonal, so anything can go anywhere but at the expense it doesn't scale up as well control flow statements do.

  • Joe (unregistered) in reply to Appalled

    If I had to maintain code like that, no one would have to verify my decomposition. Anyone would be able to smell it from a hundred paces.

  • jay (unregistered)

    My goal when programming is always to impress any future readers with what a genius the guy who wrote this must have been to be able to understand this complex code. :-)

  • Pav (unregistered)

    Are you sure you edited the source code of the "build tool" and not the compiled version? I've seen .dll files which look much the same as this.

  • Loren Pechtel (unregistered)

    When you're doing a complex ternary indenting is mandatory.

    If you can't indent to make it readable then you shouldn't do it in the first place!

Leave a comment on “A Tern at the Build Process”

Log In or post as a guest

Replying to comment #:

« Return to Article