- 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
I LOL'd on this one. Pure awesomeness.
Admin
Please, please can someone disable those annoying "Frist" comments?
Admin
im rofl'ing so hard at that =]
Admin
Fourth!
But seriously now. That was pretty funny. Almost makes you wonder if they used that var in the past, and eventually maintained the use of that var out.
Admin
Hmm maybe "this" isnt self explanatory enough.. captcha: "smile"
Admin
LOL great workaround, languages usually have this or self, he made C++ full, both with self and this.
Captcha: alarm
LOL
Admin
Nope. Doesn't count if you spell it correctly. Should be "forth" and "fith" or the like.
Regarding the SOD, I've always heard that self-scrutiny can be a good thing.
Admin
Delphi uses "Self". I program in both Delphi and JAVA and I struggle with using the wrong identify keyword. I can imagine someone got sick of trying to remember which one to use and he made it so it didn't matter
Admin
Data objects are like people. There’s the public identity but also a deeper private identity.
Enigmatic devious objects have layers and layers of identities. Here’s a handy snippet to find the true inner self of an object:
It’s fast compact code, so you’d hardly notice the performance impact.
--Rank
Admin
So instead of spending the 10 seconds to get it right, program something in that will completely baffle the next programmer that actually knows what they're doing? Brilliant...
Admin
Guessing the cause: If the destructor is called before deinitialize, this pointer may get unavailable. Maybe self is still available? It is so ugly ... marvellous! ;-)
Admin
Oh God, this is pure genious. I want to shake this guy's hand.
captcha: waffles, haha.
Admin
The writer may have come from delphi where "this" is named "self" and he or she liked the term better.
Not an excuse; just a possible reason.
Admin
So I take it the "Real WTF" (TM) here is that it's missing the const?
Admin
Does this mean the application is "self aware"?
Admin
A work around like this is needed in Javascript when dealing with virtual functions, but that certainly isn't the case here. Funny stuff.
Admin
Admin
That's hilarious!!! Look what I can do:
fnCERTlibDeinitialize( this->self->self ); fnCERTlibDeinitialize( this->self->self->self ); fnCERTlibDeinitialize( this->self->self->self->self ); ... etc.
Admin
Funny, in the one place he DID use the pointer, he used "this" anyway. Using "this->self" sure is a good way to not have to remember to use "this"
Admin
Egocentric:
Insecure:
Suicidal:
Admin
And here I thought it was going to be some bastardized attempt to implement a single-instance class.
Silly me!
Admin
It seems this class has some schizofrenic potential. It will become truly schizofrenic if self is pointed to a new class instance. To make it interesting, this should be decided at random in the constructor, with a small change for a split personality.
Here is what I mean:
Admin
What this programmer should have done was made self an instance of the SelfLocator pattern. SelfLocator has an instance variable that is initialized with whatever you pass to its constructor. So you instantiate it as new SelfLocator(this). That way you can ask SelfLocator to return your self using its getSelf() method. I think that would be much more Enterprisey-Class.
Admin
ROFLMAO at this post and at the WTF
Admin
this->self and you are this!
but if self = this, then who are you? I am this! I am this and you are self! but if you are this and I am self, and this->self and self = this, then who is he?? points to new self Arrrrgh!
captcha: mad tv's 6th day parody
Admin
Yes, but for a true split personality wouldn't you want to do this?
Think of all the nice obscure bugs that would introduce...
Admin
Maybe they were trying to implement an infinitely long linked list! Or, they were trying to find out how big of a stack they could get:
P.S.: The real WTF is that they didn't initialize 'self' in the constructor initialization list.
Admin
design patterns FTW!!!!
Admin
self.self.self.self.self.self.self.self.self.self.self.self.self.self.self.self.self.do_wtf()
Admin
"fnCERTlibDeinitialize" ... Just one thing crosses my mind: OUCH!
Admin
I'm going to go with the notion that it's a Delphi programmer making the language more like what he's used to.
Captcha: bathe. The dirty code, perhaps??
Admin
Admin
...does the deinitialize function zero out it's argument or something?
Admin
Nah, that's just self abuse.
Admin
Probably just a messed up Singleton implementation. No WTF really imho.
Admin
If this is a Delphi programmer trying to make themselves feel at home in C++, then it's similar to the WTF that I'm currently coping with. I've inherited a spaghetti like mass of Java code from a programmer who had a background as a Perl scripter. His solution to the problem of strong typing foisted upon him by Java was to use Strings for everything, and LinkedHashMaps as his only data structure. As if that wasn't bad enough, he seems to have discovered the Reflection API at some point, which gave him even more scope for writing inefficient code without type safety.
Admin
Consider this:
this->self->self->fnCERTlibDeinitialize( this->self->self ); this->self->self->self->fnCERTlibDeinitialize( this->self->self->self ); this->self->self->self->self->fnCERTlibDeinitialize( this->self->self->self->self );
Crash Magnet
Admin
Java is not an acronym.
Admin
Admin
The default copy constructor would give you something similar for free:
Admin
Don't you mean, JAVA Ain't Very Acronymy?
Admin
Couple of things.
If this really is a mixed up keyword between languages, I hope it originates from before the days of an editor which highlights keywords for you. Anyone having those sorts of problems should use one of those editors as much as possible.
When self is deinitialized, doesn't that deinitialize this as well? So isn't that memory freed, allowing the return that is implied at the end of the deinitialized function to be overwritten? If I am right, this is a potential for a very hard to find bug. If I am wrong, someone will correct me, and I will learn something else new today.
Captcha: pinball
Admin
My thought was on this was that the original programmer either was taught to do this or instinctively does this for static methods, where you don't get *this
Admin
What if he's using a smart/shared pointers, and needs an explicit pointer to the class in order to keep it alive? Based on what's displayed in the post, it appears this could be valid code.
Admin
This comment wins. (Or should that be "this->self comment wins"?)
Admin
Obviously the coder realized the truth,
You can't touch this.
Admin
In C++, any access to an object after the destructor is called is undefined. This means the program is free to do nothing, throw an exception, or reformat your hard drive. All would be valid consequences.
"self" is an instance member of the class, and is therefore unavailable after the destructor is called. Moreover, any copies of "self" squirreled away somewhere else are now dangling pointers to a destructed object. They are just undefined behavior waiting to happen.
C++ is hard.
Admin
Then TRWTF would be the lack of proper documentation.
Admin
This is a common pattern I've seen in C, where the first member of a struct is initialised to be a pointer to itself. When you're passed a pointer to such a struct, you can check it is valid:
I reckon its a relic of this kind of defensive programming and so not such a wtf as you might think.
John
Admin