- 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
Symmetrical indentation!
Admin
What do the other calls look like?
Admin
That's a Java enum type, which is implemented as a class with predefined public static final instances. So, those are a bunch of oddly formatted constructor calls. Go be learned: https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
Admin
Magic numbers! Magic numbers! Housey housey!
Admin
The code itself doesn't seem too bad, though. It seems to be an enumeration of screen elements that are added to a screen. I see Unset, Hidden, Spacer, Empty, Radio_option, radio_buttons, drop_down_single and various other statements that seem related to screen elements. It's just that the formatting is weird. As if they made it this WTF shape on purpose! Well, the methods have too many parameters but that's a common issue and not always easy to avoid. The use of magic numbers instead of constants is also a bit annoying. But the code should just work fine and might even be generated by a code generator instead of a developer. It's just that someone decided to make the formatting real messy...
Admin
These are Java constructor calls
Admin
TRWTF is using eclipse
Admin
This is truly inspiring. I think I'm going to write my next function in the shape of an erect penis…
Admin
Another case of generated code passed off as hand-written?
So TRWTF the way the pretty-printer formatted the code?
Admin
Looks like a developer passive-aggressively hating on the stupid interface they have to deal with...
I think I'd talk to the developer and maybe see if there's some kind of technical debt work they could do to improve the interface.
Admin
I suspect the specification was the worst part of this code, and the formatting is merely the programmer's way to protest the mess he was given to work with.
Admin
ASCII art strikes back!
Admin
I especially like the "&emdash" - very meta
Admin
Call your project "New direction" or something.
Admin
Proofread those emdashs
Admin
Magic numbers need to be set somewhere (even if injected from somewhere, which is not always desirable in a UI, which this looks like it is settings for). Enums are a decent place to put configuration settings (which I assume they are) if they are very static and not likely to change.
As others have said, the formatting is what is a bit weird and definitely hard to read, but I assume someone just got bored and decided to add that for fun.
Admin
Given that it's pretty clearly specifying UI elements, it smells suspiciously like programmatically generated code.
Admin
<quote>Call your project "New direction" or something.</quote>
Or "MIghtier than the sword" #whitespacematters
Admin
Admin
Some client told her to make the code pretty so the next commissioned coder could read it. The coder is being sarcastic, because she is a coder and that is the first language coders learn.
Admin
The artist wants us to contemplate the HIDDEN nature of what is TRUE, what is FALSE, and what is FILE_NOT_FOUND.
Admin
Ce n'est pas un entonnoir.
Admin
Ce n'est pas un entonnoir.
Admin
What magic happens after the DataType.STRING, in line 453? Drops of code?
Admin
The formatting is the least of your problems. (It isn't actually very readable formatting, but it's the least of your problems.)
Let's first call out the DataType thing (I assume an enum). Now, it's a little unfair to assume that it will always be STRING or UNSET, because, you know, there are tens of thousands of lines of gibberish behind and in front of this, and maybe ... just once ... there is a need for FILE_NOT_FOUND. But probably not, because this is clearly intended for a Javascript front end, where strings is strings is strings. As, basically, is everything else. That's the way Javascript works (and I don't object to it).
Now let's consider the issue of long parameter lists of booleans. This is abject. Gather them up into what C# would call a "flag enum" -- and I'm sure there's a congruent type in whatever language this is written in -- and express the desired behavior as, I dunno, "non-italic bold, no highlight, ignore font hints" or whatever.
(Which, now I come to think of it, is the entire purpose of CSS.)
This, basically, is a pathetic attempt at "fluent programming" which is only lacking one thing:
The prefix "ef."
Admin
Probably not generated code. I mean, sure, it's stupid enough. But you'd need to explain (and I bled through both eyes whilst examining the sodding thing for this purpose) why the line break in the middle of a parameter list varies between one parameter, two parameters, six (I think) parameters on the first occurrence, where a parameter is actually some sort of function call with random internal line breaks, and so on.
Also the rather lovely "funnel" effect to which Remy alludes. Code generation isn't generally bothered with this sort of thing. Cretinous programmers ... are. Does it work? Mebbe. Does it look pretty? It sure looks purdy.
Admin
Flag enum: Thanks for that, I'll bear it in mind the next time it comes up someplace. That said, if you need lots of parameters and some of them are non-Boolean, then this is a great example of why:
(a) the function definition/implementation should make them optional with sensible defaults (whenever that makes sense)
(b) the code calling the function should identify its parameters by name, e.g. SomeFunction(RowOption: X, ColumnOption: Y) rather than just SomeFunction(X, Y)
I've been bad about (b) myself in the past and it's slowly been coming back to bite me.
Admin
"most of which are false"
Nitpicking here, but at a glance it looks like more are true.
Admin
It's weird because they've not documented their enum, and the auto-formatter has got confused about where the ends of the enum members are (as the syntax is a little different from how much of the rest of Java works).
Admin
Languages in which you can write this should be banned and the ban entorced with death penalty.
What’ do you mean “you can write this in any language”?
Nevermind, death penalty remark still stands!
Admin
That's not a funnel, it's a Martini glass. The artist is clearly making his own opinion on what needs done to work with that codebase clear.
Admin
This instantly reminded me of an entry in the International Obfuscated C Code Contest - only less functional: en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest#Examples
Admin
What's the rating on the Enhanced Fujita scale?
Admin
I can't believe none of you have actually spotted the cause of the formatting. Never seen the left hand side of that before in a long email thread? You can then turn it into the full thing by viewing it on a smaller screen in a gui that copies the indenting on line breaks.
Admin
Don't see much wrong with this other than the formatting and poor naming choices.
This is a Java enum, they are used for static config, and this very much seems to be doing just that.
Admin
I'm dying to learn about lines 454 & beyond. We can see the sample truncates the final Boolean / boolean parameter of the definition of the FREE_TEXT enum entry. So far, so predictable. But then what?? Are there another dozenish enum entries formatted as a growing upright pyramid forming a hourglass with the part we can see? Or is FREE_TEXT the last one, and we're merely missing "true)}" on the final line? How anti-climactic that would be. Or perhaps, (credit to W above) it continues in drips of code? Maybe a call to process_abort() or whatever is the moral equivalent for this environment?
Enquiring minds want to know.
Admin
I don't have a lot of negative experience with Java, but is it really normal to have 96 boolean literals visible on a screenful of code at the same time? Only the formatting is unusual?
Admin
"(a) the function definition/implementation should make them optional with sensible defaults (whenever that makes sense)
(b) the code calling the function should identify its parameters by name, e.g. SomeFunction(RowOption: X, ColumnOption: Y) rather than just SomeFunction(X, Y)"
In the language of this example (Java) neither of those is possible. YMMV.