- 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
Maybe his ! key was broken.
Admin
I have code like this:
myClass::setSomething() {
m_flags = m_foo | 0x000c000e;
}
myClass::resetSomething() {
m_flags = m_foo & 0xfffffffe;
}
In the class header there is an explination for all bits, which makes it clear why the reset doesn't clear all bits that the set sets. This flag is rarely modified, normally it is read from hardware, and then latter written back out again, so not breaking all the bits out and latter re-combining them isn't an issue.
With just a little bit of code that needs to be as above, seperate setBarTrue and setBarFalse makes sense, just to keep the code consistant.
Admin
Lamest WTF ever. Accessor methods/functions are used in a variety of languages for a variety of valid reasons. Assuming this is Java, maybe iOptBln is private and they want to be sure no one sets it to null.
Admin
And a small, but much more common number of bad reasons.
Assuming this is Java, a boolean is a primitive type and cannot be null.
Admin
This one got a bunch of WTF apologists right off the bat. What is this world comming to, when bad code is explained away as "proper OO design" or "didn't want to update all the code"? I'm ashamed of my professional brethren, I'm going off to make a quick buck now.
Admin
You got me on the second one, my bad. I'm not convinced its more likely that this is bad than good, though.
Admin
I had a mentor who would, as an exercise, take a spec document and transform it directly into the code, mostly by collapsing spaces and adding punctuation, plus some use of the preprocessor. I could see a decent programmer prodcuing this code as the result of some process like that, either from a spec or from pseudo-code.
Admin
I really like the fact that this forum titles the discussion based on the title of the last post.
Admin
This is a poorly written accessor, and the whole point of an accessor is to future-proof for subclasses and requirements changes. Consider if this is in a widely-distributed library, so the API becomes unchangeable.
Later on you add an immitable subclass:
public class ImmutableWTFClass extends WTFClass {
public void setOptBlnToFalse() {
throw new IllegalArgumentException(this+" is immutable");
}
}
Next you add logging functionality:
public void setOptBlnToFalse() {
log("Set iOptBln to false");
iOptBln = false;
}
Admin
An Immutable subclass is a WTF in itself, it should be the other way around if you want to preserve the Liskov substitution principle. Though I have done this in the past... [:$]
Admin
You may give a try at the concepts of "irony" or "sarcasm"
Admin
Only if people click the appropriate reply button.
BTW the captcha image doesn't show anymore
Admin
This is simply an example, in reality this was done for all sorts of one line expressions and the name changes from place to place. Also sometimes CheckIsNull does not just check if it is null but also if it is an empty string. Every class you need to check the semantics of the method while reading a block of code.
It actually kind of reminds me about the ways operator overloading and C macros can be misused to obfuscate code.
Admin
Due to Symbian variable naming conventions. Variables defined as part of a class always have names beginning with i.
Admin
'i' for instance? Sorta kinda makes some sense - not that I am endorsing it. How are class/static variables annotated?
Admin
Member variables' names begin with "i"
.
Arguments' names begin with"a"
. Local and static variables' names have no initial letter. Global variables are usually avoided, but when used, their names begin with a capital letter (global variables cause problems when compiling dll's). Constants' names begin with "K".
Then there is own naming conventions for class names: C for heap-allocated classes, that are derived from Symbian's base class CBase (C classes have to implement Symbian's own two-phased construction). T for value classes and datatypes. R for resource classes (contains a handle to resource which is maintained elsewhere). M for abstract interface classes.
Structs are considered similiar to T classes and since enumerations are types, they have also the T prefix (but enumeration members have prefix E).
Symbian does not use Hungarian or any notation which attempts to include the variable type in its name.
As some of you may think now, Symbian itself is quite wtf... ;)
Admin
even so - you could always provide the two callback functions as wrappers around the generic setOptBln(bool) one... that way all your normal code uses the generic one and it's only the callbacks that are wierd... not that I'm endorsing actually doing that.
Admin
Here's my problem: sigother found CC bill with huge charges to "restaurants" that are really strip clubs. Do I tell him the that I habitually spend $3000/week at the club or lie and say it's all a BIG MISUNDERSTANDING? Damn. Whaddya do in this situation? Difficulty: there are 3 kids between us and he's left the house (and them; I'm with the kids) after packing.
Admin
You're fucked.
Admin
uh..... wtF?
Admin
Dunno why I'm commenting on a 4+ year old post, but anyway...
It's quite possible this is an artifact leftover from when there used to be some kind of complicated side-effects or something that made it make sense.
I have a function in a system I am delivering that, ripping out the comments, is something like this:
That's because parseDate USED TO create multiple DateFormat instances for different possible formats, attempt to parse them in try-catch blocks, falling back to the next DateFormat if it failed.... until the protocol got changed to just use milliseconds-since-epoch. Now I've got this really stupid pointless function sitting there.