- 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
Then I wonder what all these 151 Lines Of Code do.
CAPTCHA: onomatopoeia
Admin
Yes, but 151 lines of code can justify a week of pay. Trying to stretch a Boolean into 40 hours is probably going to be more difficult. There's not really much more debugging that needs to be done for it.
CAPTCHA: wigwam
Admin
YesNoFileNotFoundFactory.getFactoryInstance().YES.getDescription().equals(array[0].toUpperCase());
Admin
It looks like it does more than check a boolean value. It checks a string to see if it equals what the YesNoFactory says is "yes" or "no".
Perhaps it has to parse documents in different languages, where it can expect "Yes", "Oui" or "Ja" as input.
Admin
Nothing shows that getDescription() does more than returning a String.
Admin
I, for one, would like to see the code in its entirety. I will reserve judgment until then.
Admin
I've seen instances of stuff like this, but it was usually in the context of "there is this framework, and everything that needs to work with it is required to use the same sort of design patterns", so simple stuff winds up getting ridiculously overdesigned like this. I'm not agreeing with it; just saying that it happens.
Admin
Except that until recently, Java didn't have ENUMs...
Admin
Do I care?
Admin
Yes, but perhaps it checks your language and returns a different string depending.
Admin
I saw this post title in the RSS feed and thought "please let it be another soul-crushing pattern abuse post." I wasn't disappointed.
Admin
Some software developers deliver their source code and give the client the option of modifying it themselves. That is a very nice selling point. However, it can take away from later consulting/modification opportunities.
By including stuff like this, they can make the code virtually unreadable to inexperienced folks, or just make it too time consuming. That leads to calls from the client stating they need the developer to modify their system.
The company I work for does deliver source code (straight-forward code, not intentionally twisted beyond recognition). However, a company that did consulting modifying our code would install 2,000 lines of code with all sorts of crap to hide the 100 lines of actual useful code.
Admin
And they make fun of C having an obfuscated code contest, why?
Admin
The real WTF is they haven't added another layer of abstraction using the Spring framework.
Admin
Dale's problem is that he just doesn't understand the intricate design patterns applied here. Just use a boolean? Bah. Anyone can do that. How does that demonstrate your grasp of the complex concepts involved?
Admin
But you dont get it!
No matter what, this is what your final implementation...
Your objects will be created by a factory, and you will have to use named function to do operations like comparing
No, wait a minute...
Admin
Gads! Is this seriously professional coders turning this out?
Admin
This is a prototype for the Male/Female factory, and soon to be released On/Off factory. Copy and paste is a wonderful thing!
Admin
Admin
You're asking the wrong person.
CAPTCHA: paint (bad timing on this, it should have been "burned", dang)!
Admin
Java enums are allowed to be null, which destroys their usefulness as an enum. It's just like Java's "generics", it's just syntactic sugar, and ultimately worthless.
Admin
Admin
Wow, I didn't even notice. I've gone captch blind! yay!
Admin
You mean "..If you were to try and create a boolean as a Java enum.." As far as I know, Boolean can still be null :)
Admin
"I can't imagine a single scenario ..."
What if you don't want data, you want a model? What if the model needs to support subscribers who might be in another process written in another language running on a different server? What if you are talking to your subscribers with a lossy channel (for instance, the ultimate consumer might even be a human, who are inherently lossy) and need to keep track of your client's states as well as your own?
It would be awful to have a carefully documented and modular implementation that spans gosh, how many lines did you say, again?
Admin
Admin
Atleast he didn't do that with Integer. Consider the interface com.enterprise.factory.provider.manager.paula.web.business.1234567890.java or maybe it would have been Integer1234567890.java since who wants those classes where the classnames make no sense.
Integer1 implements Integer1234567890... jeesh how can any object implement IYesNo interface? Yes implements IYesNo (except not No). Well I guess its optional.. here is the abstract class in supercool pseudo:
Maybe implements IYesNo{ IYesNo isYes(){ throw new UnsupportedOperationException(); } IYesNo isNo(){ throw new UnsupportedOperationException(); } }
Admin
On-Off-Left; Male-Female-Turquoise; (and as posted above: True-False-FileNotFound)
Admin
I'd like if no if only a single line of these is hand-written. I suggest that s.o. created an YesNo-Entity in the (UML?) model (and we don't know if there might be some sense in it), and the code generator generated all these wonderfull classes.
I wouldn't care about such thing. They get generated, and then? Who cares? They don't eat bread.
Admin
This looks like something used in a Java course to demonstrate the use of interfaces and the factory pattern. If this got into production, it's likely from an inexperienced programmer who missed the prof telling him it's just an example and you'd use such a pattern only sparingly.
I honestly haven't seen such egregiously overengineered code myself, but here at work, most Java programmers still overuse interfaces. Just about every "business"-logic class is the single implementation of an Interface, with no way (not even a factory) to get an instance of another implementation without wholesale refactoring.
I'm one of those mavericks who insists on using interfaces only where they come in useful, with the idea that it's easier to promote a class to an interface in the future if it's needed, than it is to reduce the complexity of such code.
Admin
How about that? I think we found the guy who wrote today's wtf.
Admin
Sounds like you do. :)
Admin
Perhaps it's a useful set of code that's just awkwardly named. It's not necessarily the fault of the guy who wrote it that it was so.
Admin
Two words:
Job Security.
Admin
Classes don't store values, their instances do (in properties).
Admin
Slacker!
What's with the array[0]? Take it back and don't come back until it is completely enterprisy?
Admin
Someone should be shot. Repeatedly. With a large caliber weapon. Starting with the extremities and working inward.
Admin
What's the saying? Never attribute to malice that which is adequately explained by stupidity.
Admin
And I do. I'm just not sure that Java is the best way of getting one...
Admin
Yeah, but it's a fluent interface. Therefore, it's good because it's the flavour of the moment.
Admin
Admin
+1
Admin
Job security FTW.
Admin
You guys have it all wrong. I would assume that this factory loads the definitions from a database table. What happens in 100 years when the boolean type supports -Maybe -Somewhat -I don't know
All you people with your legacy code will be screwed, where as this application is set since they just need a minute to add the new definitions to the database.
Admin
Dude -- null means false.
Admin
Look, my point is, the WTF being presented is that someone applied a bunch of design patterns to something trivial. But, the "something trivial" is never described. We are encouraged to infer it is trivial because it probably involves a boolean value, but there's no real information. We are given evidence that several well-known patterns are being used, but we are given no evidence that they are being mis-used. We're holding some developer up for ridicule based on nothing more than some path names. That sounds pretty WTF to me.
Admin
Since Java enums are objects (another WTF for another time), you're allowed to invoke methods on them. You can't invoke methods on a null object. A simple example would be the name() method which returns the name of the constant.
By allowing null to be a legal value, you break the entire concept of a Java enum. Which, since Java allows null enums, is already broken.
Admin
True. An interface named IYesNo might model, say, a ham sandwich rather than a boolean. He's right -- there's no wtf here.
Admin
Actually you are partly wrong. Enums are fine having null values and remaining as such and this makes them NOT a boolean.
Booleans (in most languages) are two valued variables that can have a third state of uninitialized. This state effectively means null. Now if you can not safely assume a null value is actually one of two predefined values you do not have a boolean.
For example, you can have a boolean for a finished state, true means finished, false mean unfinished. If the value is uninitialized you can assume false because if the item was finished the boolean would have been specifically set to true.
Alternatively, the safe value could be True for booleans that mean something else such as an incomplete flag. In this case null = true because of the usage and name of the boolean variable.
So yes internally there are three theoretical states for a boolean variable but the null state should be safely assumed to be one of the other two states and when encountered the boolean can be safely initialized to that state effectively getting rid of all null issues.
So while the null = false statement isn't really correct, the idea behind the state is spot on. And even though java makes all enums an object and null objects don't allow the methods to be called, one used as a boolean can be safely initialized to it's safe state and then used.
Admin
...The Real WTF(tm) is obviously the use of C#-istic "I" prefix on a Java interface...