- 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
Wow, they acknowledged the interface but I guess setBillOfLadingNumber was just too verbose and needed to be shortened to setBOLNumber. That's like 9 characters you're saving there! Just to be sure you don't use those old unwieldy functions it was nice of the author to make them completely non-functional. If they had chained them onto the new methods that would just encourage bad style and that's no good for a slick program like this. I can think of one improvement though, just to be sure you are using the new functions the setBillOfLadingNumber and getBillOfLadingNumber should probably throw an IDontLikeThisMethodNameException. You know, for clarity.
Admin
The developer of this code was probably going for performance here. If you call a method from an interface or an inherited method for that matter the compiler has to trace through the stack until it gets to the original function that is stored on the heap in most cases, which can be rather slow (thats why you will occasionally see a "stack overflow" error, in case you didn't know).
By creating different, but similarly named functions the stack traversal does not need to occur, but the interface is still implemented.
The only WTF I see is that setBOLNumber should return a return code to let you know that the value was successfully assigned, perhaps the code could return the number of characters in billOfLadingNumber so the caller could compare that to how many characters were sent, making sure the value was not changed along the way.
Admin
Re: "The only WTF I see is that setBOLNumber should return a return code to let you know that the value was successfully assigned, perhaps the code could return the number of characters in billOfLadingNumber so the caller could compare that to how many characters were sent, making sure the value was not changed along the way."
That is certainly thorough checking, which I would not normally argue against. But in this case, if you cannot trust your compiler to perform a simple string assigment, you are in a much bigger world of hurt.
About the only way this could possibly fail that I can think of is lack of memory to allocate for the string. Given that thinking, you may as well put a try-catch block around every assignment to an object type that ever happens in code, in case the system doesn't have enough memory to allocate the new object.
Admin
I would send it an XML document with a <checksum/>. That would make it reliable and cross-platform too. I haven't tried using Javascript yet, but it's on my to-do list.
Admin
Don't forget to write a SOAP interface for it!
Admin
You have been trolled. Have a nice day.
Admin
So I am. It was well-hidden amongst what could conceivably be a non-troll's (ignorant) opinion.
I guess I truly am in the "Not Getting It" group.
I'll stick with assuming people are attempting to actually have a discussion as I am, and not play silly message board games as they are. Otherwise, I'd never respond to any anonymous posts ever again...
Then again, that might not be so bad either. [*-)]
Admin
Ummm,
You're wrong on so many counts..
1) You need to read up on basic virtual function handling before you go off making half-cocked comments like this. The derived class will have in its vtable the address of the function, there is no tracing through the stack, though there is the small penalty of looking up the address of the function in the table before the function call can be made.
2) A "Stack Overflow" error is generally caused by some program being thrown into some infinite recursion loop, causing the stack to eventually fill up and overflow, either that or you've got bigger problems with your code and probably need it to be posted on "The Daily WTF".
I do, however agree with you on the point about returning a code. BUT This example is either C# or Java, and wouldn't matter... An exception would be thrown if the string space could not be allocated, and could be cought later in the program. If this were a COM-based application, I'd return the appropriate HRESULT, so the calling function could handle this condition appropriately.
Admin
Ok, so am I in the majority or minority here?
I see that I'm not the only one "Not Getting It", so at least I know I'm not alone.
Admin
I assumed it was a troll, just because I couldn't believe anyone could really be that stupid. I mean, what's the point of implementing an interface in the first place, if you're going to totally disregard its methods because of a supposed performance hit?
I say that from now on, we all just ignore people who post anonymously. I can't think of one good reason---aside from cowardice or laziness or some other deadly sin---that anyone here needs to post anonymously. So let's just ignore them until they register. Who's with me?
Admin
I am not the author of this post, but I think it is pretty clearly a "troll."
Here is why I think so:
The developer of this code was probably going for performance here.
Right off, defending the WTF as "good code."
If you call a method from an interface or an inherited method for that matter the compiler has to trace through the stack until it gets to the original function that is stored on the heap in most cases, which can be rather slow (thats why you will occasionally see a "stack overflow" error, in case you didn't know).
This is just made-up sillyness. You can count on somebody responding to "clarify."
By creating different, but similarly named functions the stack traversal does not need to occur, but the interface is still implemented.
This doesn't make any sense. The interface is implemented because the required methods are there. The similarly named functions don't do anything towards that goal.
The only WTF I see is that setBOLNumber should return a return code to let you know that the value was successfully assigned, perhaps the code could return the number of characters in billOfLadingNumber so the caller could compare that to how many characters were sent, making sure the value was not changed along the way.
Come on. "Making sure the value was not changed" ? What is going to change it, alpha radiation hitting the CPU? This is more nonsense.
I got a good laugh out of this post because it is absurd, much like British comedy. (E.g. Monty Python. Nobody expects the Anonymous Defenders!)
Admin
Read the first post in the thread -- clearly sarcasm, well-written and it conveys that idea. Read the other one -- who knows what the hell the person intended? As mentioned in another thread, if you're going to be witty or clever or sarcastic, but you cannot communicate that concept effectively then who's fault it that?
It's like someone with a really bad sense of humor, who cannot create/deliver jokes properly and has poor communication/social skills: "Hey John did you hear? Your entire family got killed in a car crash just now. Yeah, they all died ... It was pretty horrible .... ha ! got ya! I was joking! woo-hoo! You should've seen the look on your face! ha ha, that was a good one, huh? Come on, lighten up, it was funny!"
Admin
What would be even better is seeing code that refers to the implemenation instead of the interface, sprinkled all over in the code, just to access the "enhanced" methods.
Admin
<FONT style="BACKGROUND-COLOR: #efefef">Jeff, do you mind if I use that car crash joke? Thats good stuff.</FONT>
Admin
Anonymous (most recent),
Re: "Right off, defending the WTF as "good code.""
People seriously do this on a regular basis, so it isn't a good indicator.
Re: "This is just made-up sillyness."
Ditto my coment above, with the addition that they may be 1) clueless newbies talking out of their ass, 2) otherwise clueless people talking out of their ass.
Re: "This doesn't make any sense."
Ditto my first comment.
Re: "This is more nonsense."
Yet again, ditto my first comment.
I mean, there isn't even a single exclamation point, which is usually put in for sarcasm for those too lazy or otherwise uninclined to use more explicit notation.
I'm sorry, but I haven't seen a single thing you've said that can be claimed as an absolute rule in declaring something trollish / sarcastic.
Admin
I'm not even going to bother reposting. If you want to read it, crank up your browser font size or copy / paste it into Notepad.
Admin
>>If you call a method from an interface or an inherited method for that matter the compiler has to trace through the stack until it gets to the original function that is stored on the heap in most cases, which can be rather slow (thats why you will occasionally see a "stack overflow" error, in case you didn't know).
I guess with the above quote, you can only assume it's a troll... I mean, can anyone really be THAT dumb?
And I don't think they were trying to be sarcastic/clever -- though, as I mentioned, I suppose it is possible they were trying to be but failed miserably ...
So, it's gotta be a troll ... for the sake of mankind, I hope it is!
Admin
Sorry but I have to say this, I think this site really suffers lately from people that troll these forums, but moreover people who respond to all these WTF's / trolls so seriously and defend them / clarify them / write their own code how it should've been done.
Guys, this site is simply for fun, and to laugh at some code people write. Not to start endless discussions about how stacks work, or how the code should've looked like, or try to find every little mistake in the code other than the intented 'WTF' and label it as some other major WTF because clearly, everybody posting here must let everyone know how superior he / she is and think every little error in a piece of code is a WTF.
Just... 2... cents... :)
Admin
Yes, I know, an Anonymous posting...
I've been reading DailyWTF since it began, and I have to agree with the reply above, that the comments are getting pretty useless nowadays.
Just look at this thread, a discusion about if some reply is a troll or not? That's even more WTF! In the begin it was a good laugh, now it's just more of the same, resulting in every thread being totally besides the point
Admin
Couldn't agree more. Besides, this isn't even a WTF. It just looks like an incomplete refactoring to me.
I wouldn't exclaim "WTF" if I saw code like this. I'd just think "Ah, you forgot to rename your methods after introducing the new interface, you silly sod".
Admin
Erm, actually you've just seen the difference between sarcasm and irony. Sarcasm was present in the first one == holding up vice/folly and making witty comments about how bad it is for the betterment of all of us (ie what this website is all about). Irony, OTOH is the purposeful taking of the opposite stance (and generally exaggerating it) to better outline the folly by showing people how bad it is... ie trolling is irony by its very nature.
Now some (not all) English humour (as opposed to most American humour) tends to hold high the concept that you are better/more intelligent/whatever if the one being ironic can almost but not quite hide the fact that they are being ironic and the listener can still get it. Ie English humour depends on the skill of the listener in some instances - and not at all in the sort of tactless way that you mention in the car-crash example, true irony is a subtle mental challenge, and therin lies the fun.
You may or may not like it - but it's actually one of my favourite kinds of humour. It is a humourous mystery epitomised by the straight-faced delivery of some outrageous tall tale - in the hopes of seeing who will "get it" and who will fall for it... and (with kinder joke-tellers) with the intention that we will all profit from the advernture. In this case, the poster no doubt sought to further outline the folly of poor coding.
The post was a good example of irony - and the anonymous post describing the clues the joke-teller gave pointed out that the clues were there, you just failed to notice what they meant. Contrary to what Blue is worried about, this is not to say that anyone that doesn't "get it" is stupid or anything - you just fell for the verbal equivalent of a practical joke - albeit a subtle one. It generally takes quite a bit of familiarity - not only with the joke-style, but often also with the specifc joker to be able to get their jokes.
Admin
<font face="Georgia">I see the bug! I see the bug! It should have been written like this:
<font face="Georgia">Obvious!</font></font>
Admin
<font face="Georgia">Posting irony here is unfair! After all, if you post something that can only be read by white people, or men, or people who aren't physically disabled, then you're practising discrimination, which is blatantly unreasonable, right? Well, we've now seen that a significant number of people have approximately the same understanding of irony as Alanis Morisette, so continuing to use it is just as discriminatory.
</font>
Admin
<FONT style="BACKGROUND-COLOR: #efefef">Cheer up, and don't assume the worst in all comments. Guess there is a little culture collision going on on this site. Sorry for the generalization here, but for example what somebody from France considers funny may not have the same humorous effect on somebody from Norway (after watching a French comedy movie that is true for me [;)]).</FONT>
Remember from a "Welcome to Oz" session/speech at the university I studied at they actually explained Australian humor(often irony) to us students from abroad. So, they showed a few sketches with ironic humor. Guess they've experienced that not all cultures take/use irony...
With a start line of "The developer of this code was probably going for performance here. If you call a method from..." I find that it is written with the intention of being funny. Basicly there are three ways(more?) to make the WTF more funny: 1) Geeky way: rip the code apart and explain all places it's wrong and maybe some implications, 2) Defensive way: Make up some funny excuse for the code (like above). Seems like these often are misunderstood here[:)] and finally 3) tell a story about something similar.
Hope some vote-button will come soon, would be nice to be able to vote "funny/not funny" or something like that and see that it ends in a tie [;)]
Admin
Is the interface really implemented just by writing non-functional methods? I know, there are probably some parts of the interface that really have been implemented. But is there a reason to return null, why not return billOfLadingNumber in two methods if that's necessary.
Admin
wtf?
What the f*ck! (= first impression)
Why the f*ck! (= second impression)
Who the f*ck! (= third impression)
Admin
No no no - please don't stop! It's people's failure to spot irony that makes this site what it is!
To me the ironies are always apparent, but whenever an ironic response appears I know someone's going to miss the point and I always look forward to the barrage of abuse its 'inaccuracies' will attract.
Admin
(Since I'm not going to load another browser and log in just to be able to quote properly beacuse the forum software sucks, this'll just be randomly adressed. Did I mention the forum software sucks? Also, the forum software sucks. Thank you for taking note that the forum software sucks.)
Regarding the "Not Getting It", this is the way I see it. Let's, for simplicity's sake, assume there are three kinds of posts - serious, humorous and plain stupid. Which one the trolls belong in is left as an excercise for the reader. If I were to read a post and not be entirely certain about which category in which to place it, my reasons for /not/ responding at all would be these:
Let's say it was seriously meant. If, to me, it was plain stupid, I would probably be on such a level that the person having written it wouldn't understand what I said anyway, or I would be completely mistaken and the roles would be reversed. Either way, the net effect of posting a reply would be negative for everyone involved.
If, on the other hand, it was meant as humour, but I couldn't see it, posting an irate or corrective reply would make me out as the fool for those that by some freak chance (for instance by having enjoyed too much brit humour) did get it. While this may produce some amusement value for some, none for me.
Lastly, if indeed it was plain stupid, and not even meant in seriousness, the only effect a response will have is to increase the noise in the forum. Score one for the trolls.
What I'm really trying to say here is this: If you don't see the point of a certain posting, there's likely even less point in you responding to it.
Okay, come on. Who put this soapbox here? gets down again
On the subject of subtle irony, I'm thinking fans of either Red Dwarf, Monty Python or (gasp!) even Dr. Who are far more likely to Get It than, say, someone who never misses one of Chris Rock's performances.
Admin
I have it!
The programmer thought that "Bill of Lading" was supposed to be spelled "Bill of Landing", and so just renamed it BOL without updating the interface...
Stranger things have happened....
Admin
Hi. Long-time listener, first time caller.
I appreciate the irony in the troll. That's my kind of meatball.
Furthermore, it's edifying to read the responses which pick apart the meatball. Hedge your bets: tap down the vitriol, crank up the pedantry, and in the case YHBT, at least you may have learned someone something good.
. o * ( The More You Know )
Admin
Son of a bitch. I created an account for nothing. LOGIN, DUH.
Admin
Here's the problem - to you the ironies are always apparent because you assume that anyone who posts something so inaccurate or stupid could not possibly be serious. The problem is, that assumption is proven wrong every day by the code Alex posts. There ARE people that are that stupid, there WAS someone who thought this was good code - the guy who wrote it. So could you fill us in on how you can differentiate between someone who is being ironic and someone who is woefully uninformed?
Admin
geez u guys need to get a life, these replies are really starting to bring this site down. [B][:#]
Admin
"Now that's comedy."
Admin
sorry, maybe i should explain myself: for me this site has been cool because now and then i can pull in, laugh at some stupid code, and see some funny responses. nowadays theres no point in reading the replies. maybe disallow anonymous posts? just a though.
Admin
I've been reading the site since it began and this is my first comment...
I don't see how the stupid coments are bringing the site down. I read all of these today, hoping to see some actually relevant to the code, but alas, there were none.
Anyway, I read the site for the WTF code and Alex's often witty presentation of them.
All these comments about comments are just crazy. And it wasn't much of a WTF in the first place - unlike yesterdys stupid way of reading a DB count, or older posts, e.g. methods that always return true, or all the great examples of verbose code where clueless developers write hundreds of lines to reinvent the wheel. This one was just silly.
Hopefully tomorrow's WTF will be better.
Admin
OK, getting back to the original matter at hand (the code), here's my theory on how this came about:
The class was originally write sans the interface, and using getBOLNumber / setBOLNumber. Later the author learned about interfaces, figured one might to useful here, and defines the Shipment interface --- giving the property a better name in the process. Then realizes that using the interface would require making lots of code changes (changing calls to setBOLNumber into calls to setBillOfLadingNumber) and forgets about it.
Visual C#.Net will automatically create dummy functions like that for you when you type "implements Shipment". I'm guessing whatever editor he used to write this (it's Java, right?) does the same thing.
Admin
Long time poster - first time making an account
Since I have worked with such people in the past, am working with such people now, and will probably work with such people in the future - I just assume that the trolls are ill-informed. I don't really want to assume that every anon posting is from someone that thinks they are being clever, but prefer to just think of them as not being up to speed. We all started somewhere thinking that our code was being "of so clever", so I just believe that the new crop of programmers are no different.
Admin
Visual C# will do that for you if you have the option turned on, and I'm not sure it was in VS2001. But I think it's rather a neat option in VS2003. Unless you don't know it does so and keep trying different interfaces till you get one which sounds right and you end up with 30 empty functions in your code [:P]
Drak
Admin
(my last post regarding this subject -- YEAY!)
And that is why, if you want to contribute something, just put a damn signature at the bottom of your anon post so we can get to know you. it doesn't have to be your real name -- it can be a "cool hacker name" like "kew1 h4ck3r" or whatever.
People are confusing irony with stupid comments or trolls. If I post "today is March 1st", but it's not, am I wrong or am I being "ironic"? And if I am trying to be ironic, was I succesful? Are you an idiot if you couldn't detect my intent? Am I "clever" for hiding my true indent so succesfully but making no effort whatsoever to express it? This is really getting out of hand. And people posting and bragging about their powers and capabilities to surmize the true intent of every post -- come on. It's just stupid. Get over it.
But the main point is: If you want to write clever, ironic posts, then just sign the damn things. Then we can get to know you, and know your style, and know who you are. Maybe not the real you or your real name (i.e., "blue" might not be his legal name I bet) but so we can appreciate your posts and better interpret them after we get to know your style and get to know the fact that you know what you are talking about ... Is this really so difficult to understand?
If I walk up to you on the street anonymously and say "Tomorrow it will snow" and then I simply walk away -- am I an idiot? Am I guessing? Am I misinformed? Am I right? Am I a weather man? Am I being "clever" and "ironic" because it is the middle of summer?
The answer: I was too vague as to my true intent and therefore I failed to successfully convey my message. The person I spoke to isn't "not getting it" for not being able to intrepret where I am coming from. I failed to deliver the message.
Take responsibility for your posts, guy and gals.
Admin
Good theory, but if he's going to implement the interface he ought to at least make the interface functions call his own functions. The whole point of implementing the interface is to indicate that it performs certain functionality. If all he does is return null, he's not really implenting the interface.
Admin
Actually, originally, I used to find everyone attacking the trolling/sarcasm/irony/whatever tiresome, but I'm starting to find it pretty funny. But, that first one? ("The developer of this code was probably going for performance here...") If that wasn't sarcasm, I don't know what is.
Incidentally, WHY WON'T THIS LET ME LOG IN, DAMNIT?!
~ Irrelevant<font color="#d3d3d3" size="1"> (not the Anonymous you are looking for)</font>
Admin
Re: "Guys, this site is simply for fun, and to laugh at some code people write. Not to start endless discussions about how stacks work, or how the code should've looked like, or try to find every little mistake in the code other than the intented 'WTF' and label it as some other major WTF because clearly, everybody posting here must let everyone know how superior he / she is and think every little error in a piece of code is a WTF."
I partially disagree with you.
Yes, this site is for fun, but not simply for fun. As many have stated previously, it also presents learning opportunities. In order to explore those opportunities, one by definition must attempt to discuss a variety of programming topics. While there are some that do it out of ego, many are in fact sincere. Given your viewpoint, a thread on this forum should only have the original WTF, and at most 1 or 2 replies pointing out exactly what the WTF is. All other discussion would be in violation of what you state, as I understand it. That would quickly become boring, and you certainly wouldn't find me sticking around.
Sarcasm and Irony also have a welcome, proper place here. There are times when it is difficult for some of to discern between stupidity and sarcasm/irony, but that comes in hand with the useful programming discussions and cannot be prevented. If I respond to a sarcastic or ironic post as though it was serious, I suppose it's my bad, and I can laugh at myself for it.
My ability to detect subtle irony is impaired due to my extremely literal nature. In my opinion, those who are trying to be subtly ironic are more annoying in attempting to demonstrate their superior wit than those you take issue with who are attempting to demonstrate their programming superiority. In the former case, there is no useful response or further discourse. You either a) Ignore it (waste of time even bothering to read it), b) fall for it (other than a laugh by the ironic posted, this gains nothing for anyone), c) say ha-ha (and help inflate the ego of the witty poster). In the latter case, there is the possibility of seriously discussing the issue further, and perhaps learning or teaching something in the process.
However, for certain people, fun involves posting inane crap on purpose to bait people and see how they will respond. In addition, sometimes making fun of responders for falling for it. These are the posts I am at issue with.
Admin
Meester Anon: You might have blocked cookies from the site when you first started visiting it. If it's not that, I have no idea.
Admin
Dudes, it was clearly meant to be a joke. The author was clearly "explaining" the lame coding with nonsense. I thought it was pretty funny. Searching for method requires stack space?!?? Good stuff.
***
No, I'm not that other Anonymous guy. I'm a random infrequent reader.
Admin
This post precedes Rickrolling by 2 years!