- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Thanks for "readability". Ouch.
Admin
One good tern deserves another. Actually APL is easier to read then that mess.
Admin
*than
Admin
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.
Admin
Maybe he meant that APL was easier to read, followed by that mess... ¯_(ツ)_/¯
Admin
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.
Admin
At least they used parenthesis. They help a (very) little.
Admin
The easy reader version is not readable.
Admin
I think you dropped this: \
Admin
There is a season, tern, tern, tern.
Admin
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.
Admin
Condolences.
Admin
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.
Admin
So the WTF is someone who can't face changing code?
Admin
I bet this looks just as lovely with if-else
Admin
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.
Admin
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.
Admin
I have a translation matrix using cascading switch statements. It's like this, but without ternaries. Only marginally more readable though.
Admin
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.
Admin
This is what almost all perl code looks like to me. Except with more regexps to make things more 'readable'.
Admin
What language is this?
Admin
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.
Admin
pig Klingon?
Admin
We can't stop here! This is "if this then that" country!
Admin
Hmm, so if my if else is formatted like so...
I could format a ternary similarly:
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.
Admin
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.
Admin
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. :-)
Admin
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.
Admin
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!