Comment On Not the Most Thought Out Enumeration

Chris M is part of team that’s responsible for maintaining a giant mess that was once a fairly simple C++ application. Like so many organically grown behemoths, this application has its share of bad and rotting code. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Not the Most Thought Out Enumeration

2007-07-13 09:35 • by AdT (unregistered)
There's a perfectly good explanation for this: bool was NIH.

Frist?

Re: Not the Most Thought Out Enumeration

2007-07-13 09:36 • by akatherder
Cue the YesNoFileNotFound permutations.

Re: Not the Most Thought Out Enumeration

2007-07-13 09:36 • by Gerald (unregistered)
substract 1 and take the absolute. then suddenly the values are the right way round

Re: Not the Most Thought Out Enumeration

2007-07-13 09:36 • by ozangunceler (unregistered)
Man! What were they thinking ?

Re: Not the Most Thought Out Enumeration

2007-07-13 09:39 • by Tobs3n (unregistered)
haha..."Do you think your enumeration is sane?" NOT!

Re: Not the Most Thought Out Enumeration

2007-07-13 09:40 • by Bad Taste (unregistered)
Was this coded by someone who believed that when she says 'No!' that it really means 'Yes!'?

Re: Not the Most Thought Out Enumeration

2007-07-13 09:41 • by TexDex (unregistered)
It sounds as if the person who wrote that perhaps spoke English as a second language. For native English speakers the instinctive opposite of "Yes" is "No", but others may easily make the mistake, especially if their native language isn't closely equivalent. For example, I'm horrible at remembering the genders of German nouns.

Working at an e-commerce company that farms a little bit of the dev work out to India, I see things like this occasionally. Once I saw a variable "boolean allowGiftWrape".

Re: Not the Most Thought Out Enumeration

2007-07-13 09:47 • by IP (unregistered)
Hey, why the link in the first reply go to yahoo to get to wikipedia?

Re: Not the Most Thought Out Enumeration

2007-07-13 10:13 • by Simon (unregistered)
It's opposite day!

Two comments

2007-07-13 10:13 • by inglorion (unregistered)
Two things immediately leapt to my mind when I read about the debugger:

1. In the Bourne shell, an exit code of 0 indicates success, and any other indicates an error. Sensibly, the boolean logic of the shell uses 0 as true and any other value as false.

2. The fact that your debugger displays the enum values as numbers, thus making it hard for you to understand what they mean, is the fault of the debugger, or perhaps the programming language; not of the programmer who wrote the program.

The code is still insane, though.

Re: Not the Most Thought Out Enumeration

2007-07-13 10:31 • by /b/ (unregistered)
i still like BoolPlus best:

Yes, No, Perhaps

Re: Not the Most Thought Out Enumeration

2007-07-13 10:33 • by rbowes
145424 in reply to 145419
inglorion:
Two things immediately leapt to my mind when I read about the debugger:

1. In the Bourne shell, an exit code of 0 indicates success, and any other indicates an error. Sensibly, the boolean logic of the shell uses 0 as true and any other value as false.

2. The fact that your debugger displays the enum values as numbers, thus making it hard for you to understand what they mean, is the fault of the debugger, or perhaps the programming language; not of the programmer who wrote the program.

The code is still insane, though.

1. Only if the question is, "was it successful?" and not "what's the error code?"

2. Perhaps it isn't compiled with symbols for whatever reason.

Re: Not the Most Thought Out Enumeration

2007-07-13 10:34 • by XIU
145425 in reply to 145417
IP:
Hey, why the link in the first reply go to yahoo to get to wikipedia?


I noticed that Google does that too, when you search for something and hover over an url it shows the normal one, but when you copy it it has all this google crap before it.

Re: Not the Most Thought Out Enumeration

2007-07-13 10:36 • by AdT (unregistered)
145426 in reply to 145417
IP:
Hey, why the link in the first reply go to yahoo to get to wikipedia?


Because I copied the link from the Yahoo results page. Didn't consider the stupid redirect, sorry. This is the correct link.

Re: Not the Most Thought Out Enumeration

2007-07-13 10:42 • by Mikolaj (unregistered)
They should just change the order of enums.
For any well written application it should have absolutely no effect...

Re: Not the Most Thought Out Enumeration

2007-07-13 10:49 • by sir_flexalot
Yes means No and Not means Yes. Does this code suck?

Re: Not the Most Thought Out Enumeration

2007-07-13 10:50 • by poochner
145429 in reply to 145427
Mikolaj:
They should just change the order of enums.
For any well written application it should have absolutely no effect...

As long as it's not a library exposing an ABI.

Re: Not the Most Thought Out Enumeration

2007-07-13 10:58 • by T$ (unregistered)
145432 in reply to 145428
sir_flexalot:
Yes means No and Not means Yes. Does this code suck?

0

Re: Not the Most Thought Out Enumeration

2007-07-13 11:04 • by Anonymous Coward (unregistered)
145433 in reply to 145415
TexDex:
Working at an e-commerce company that farms a little bit of the dev work out to India, I see things like this occasionally. Once I saw a variable "boolean allowGiftWrape".


Here (in Germany, at University) i maintain an application that has database fields "firstname" and "sirname". Maybe a simple typo, but could be a lack of understanding also.

Re: Not the Most Thought Out Enumeration

2007-07-13 11:14 • by Mikoangelo
145438 in reply to 145418
Simon:
It's opposite day!


Yes, it is.

Re: Not the Most Thought Out Enumeration

2007-07-13 11:23 • by T$ (unregistered)
145444 in reply to 145438
Mikoangelo:
Simon:
It's opposite day!


Yes, it is.


No it isn't. Now who's telling the truth, me or Mikoangelo?

Re: Not the Most Thought Out Enumeration

2007-07-13 11:24 • by Sven (unregistered)
145445 in reply to 145428
sir_flexalot:
Yes means No and Not means Yes. Does this code suck?

X Cancel?

Re: Not the Most Thought Out Enumeration

2007-07-13 11:31 • by whiny wee bastard (unregistered)
145449 in reply to 145415
TexDex:
It sounds as if the person who wrote that perhaps spoke English as a second language. For native English speakers the instinctive opposite of "Yes" is "No", but others may easily make the mistake, especially if their native language isn't closely equivalent. For example, I'm horrible at remembering the genders of German nouns.

Working at an e-commerce company that farms a little bit of the dev work out to India, I see things like this occasionally. Once I saw a variable "boolean allowGiftWrape".


Yes, as a non-native speaker of English, I often misplace my W's too.

Re: Not the Most Thought Out Enumeration

2007-07-13 11:41 • by FredSaw
Some id10t did the same thing in one of our apps. It's still there, complete with a comment by a frustrated subsequent developer:

foreach( ResponseTypeEntity type in _responseTypes)

{
if (type.ResponseTypeId == 1) // indicates a negative response. I know. The dumbass did it backward.
{
txtNo.Text = type.ResponseName;
txtNo.Enabled = true;
}
else if (type.ResponseTypeId == 0) // indicates a positive response
{
txtYes.Text = type.ResponseName;
txtYes.Enabled = true;
}
}

Re: Not the Most Thought Out Enumeration

2007-07-13 11:59 • by Grant (unregistered)
Before I saw that it was C++, I thought maybe 'no' was a keyword.

Like you've never had to use 'klass' instead of class, or 'type_' instead of type.

Re: Not the Most Thought Out Enumeration

2007-07-13 12:29 • by rawsteak
Borat: This Yes is NOT 0.

captcha: NOT!

Re: Not the Most Thought Out Enumeration

2007-07-13 12:44 • by Gert (unregistered)
145496 in reply to 145411
yeah, along the way you could also multiply with 100 and divide with the square of 10
... or just subtract the int value from 1

Re: Not the Most Thought Out Enumeration

2007-07-13 12:50 • by Zygo (unregistered)
145500 in reply to 145444
T$:
Mikoangelo:
Simon:
It's opposite day!


Yes, it is.


No it isn't. Now who's telling the truth, me or Mikoangelo?


Mikoangelo, if I remember my logic puzzles correctly...

Re: Not the Most Thought Out Enumeration

2007-07-13 13:03 • by Zygo (unregistered)
145505 in reply to 145500
Zygo:
T$:
Mikoangelo:
Simon:
It's opposite day!


Yes, it is.


No it isn't. Now who's telling the truth, me or Mikoangelo?


Mikoangelo, if I remember my logic puzzles correctly...


Oops, I don't remember it correctly. The puzzle I'm thinking of has a different solution (T$, if I asked Mikoangelo myself, would he say it's opposite day?).

In any case, Simon is clearly lying. ;-)

Re: Not the Most Thought Out Enumeration

2007-07-13 13:07 • by Jno (unregistered)
145508 in reply to 145500
Zygo:
T$:
Mikoangelo:
Simon:
It's opposite day!


Yes, it is.


No it isn't. Now who's telling the truth, me or Mikoangelo?


Mikoangelo, if I remember my logic puzzles correctly...

Depends if you are Pukkas, Shilli-Shallas or WottaWoppas. If I was to ask Mikoangelo which tribe he belonged to, what would he say?

http://mathforum.org/dr.math/faq/faq.liar.html

Re: Not the Most Thought Out Enumeration

2007-07-13 13:17 • by Jon W (unregistered)

That enum is SO missing a "Brillant" entry.

Anyway, the enum writer was probably a fan of Waynes World. Which probably tells us the age of the code (or the author).

Captcha: "quake". Now where did I put that CD?

Re: Not the Most Thought Out Enumeration

2007-07-13 13:28 • by AnonCoder (unregistered)
Yes that code is a horrendous WTF.

The only bigger WTF is that it wasn't immediately refactored the first time someone with a clue saw it.

Re: Not the Most Thought Out Enumeration

2007-07-13 13:36 • by nobody (unregistered)
So... anything that is not Yes is TRUE and therefor No, which is the opposite of FALSE, which in turn is Yes?

At least the triple negation works... sorta.

Re: Not the Most Thought Out Enumeration

2007-07-13 13:59 • by savar
145523 in reply to 145411
Gerald:
substract 1 and take the absolute. then suddenly the values are the right way round


or..
i = (1-i)

Re: Not the Most Thought Out Enumeration

2007-07-13 14:09 • by Rank Amateur
Yes, that is false.
That is not false.

What's so hard about it?

Especially once you understand these are allowed answers to the following question: "Is it false to say that the value isn't true?"

--Rank

Re: Not the Most Thought Out Enumeration

2007-07-13 14:39 • by foxyshadis
145532 in reply to 145427
Mikolaj:
They should just change the order of enums.
For any well written application it should have absolutely no effect...
And then you find out it was serialized to a database.

Re: Not the Most Thought Out Enumeration

2007-07-13 14:40 • by sas
145533 in reply to 145418
You're lying if you say it's Opposite Day. You can only say It's NOT Opposite Day!

Re: Not the Most Thought Out Enumeration

2007-07-13 15:07 • by jjacksonRIAB (unregistered)
145537 in reply to 145411
Gerald:
substract 1 and take the absolute. then suddenly the values are the right way round


Or just subtract from 1 and forget the absolute. :-)

Re: Not the Most Thought Out Enumeration

2007-07-13 15:14 • by pitchingchris
I don't agree with the code, but if they just were enums to a push button response, and they matched the proper one to the proper event, no one would ever know.

Re: Not the Most Thought Out Enumeration

2007-07-13 15:38 • by shadowman
145545 in reply to 145540
This suit is black! Not!

Re: Not the Most Thought Out Enumeration

2007-07-13 15:58 • by Coyne (unregistered)
145549 in reply to 145411
Gerald:
substract 1 and take the absolute. then suddenly the values are the right way round


Much easier and even more confusing if you subtract from 1:

    (1 - var)

Re: Not the Most Thought Out Enumeration

2007-07-13 16:14 • by mattmoss
145550 in reply to 145549
Coyne:
Gerald:
substract 1 and take the absolute. then suddenly the values are the right way round


Much easier and even more confusing if you subtract from 1:

    (1 - var)



I was going to suggest the same, but let's use the enumeration values, shall we?

Not - Not => Yes.
Not - Yes => Not.

Does that mean two wrongs make a right? Hmm...

Not + Not => 2

Guess naught.

Re: Not the Most Thought Out Enumeration

2007-07-13 16:41 • by a/c (unregistered)
145553 in reply to 145455
FredSaw:
Some id10t did the same thing in one of our apps. It's still there, complete with a comment by a frustrated subsequent developer:

foreach( ResponseTypeEntity type in _responseTypes)

{
if (type.ResponseTypeId == 1) // indicates a negative response. I know. The dumbass did it backward.
{
txtNo.Text = type.ResponseName;
txtNo.Enabled = true;
}
else if (type.ResponseTypeId == 0) // indicates a positive response
{
txtYes.Text = type.ResponseName;
txtYes.Enabled = true;
}
}


The WTF is that you're using magic numbers to test the result. You have to remember the inverted logic every time you use it. Chances are you're gonna screw up at least once and it'll cause problems. Defining it as an enum like the original WTF actually makes more sense.

Re: Not the Most Thought Out Enumeration

2007-07-13 16:43 • by Zylon
145555 in reply to 145433
Anonymous Coward:
Here (in Germany, at University) i maintain an application that has database fields "firstname" and "sirname". Maybe a simple typo, but could be a lack of understanding also.

Why would you think it was anything other than a misspelling of "surname"? "U" and "I" are even right next to each other on the keyboard.

Re: Not the Most Thought Out Enumeration

2007-07-13 17:31 • by iMalc (unregistered)
145561 in reply to 145550
mattmoss:

Does that mean two wrongs make a right? Hmm...

Not + Not => 2

Guess naught.

Ah but two right's make a right, right?
Yes + Yes => Yes!

Re: Not the Most Thought Out Enumeration

2007-07-13 18:19 • by Cewl (unregistered)
Perhaps as a response to the question "Is it false that you want to download or not"?


enum TypeDlYesNo
{
Yes,
Not
};

Re: Not the Most Thought Out Enumeration

2007-07-13 19:24 • by Phyzz (unregistered)
145573 in reply to 145561
iMalc:
mattmoss:

Does that mean two wrongs make a right? Hmm...

Not + Not => 2

Guess naught.

Ah but two right's make a right, right?
Yes + Yes => Yes!


I'll have what that enum is having.

Re: Not the Most Thought Out Enumeration

2007-07-13 21:44 • by FredSaw
145581 in reply to 145553
a/c:
The WTF is that you're using magic numbers to test the result. You have to remember the inverted logic every time you use it. Chances are you're gonna screw up at least once and it'll cause problems. Defining it as an enum like the original WTF actually makes more sense.
Would that the original author had done so. This was a fairly large application, involving calls to the database-stored "ResponseTypeId" records from multiple modules, and I was only assigned to correct one simple coding error with it. I assume my frustrated predecessor was assigned no more than that, as well. Let the record show that the original code was outsourced from America to India.

I'm sure either of us would have been happy to try to rewrite the application to switch yes=0, no=1 for yes=1,no=0. But that was not our assignment, and so we were doomed--he to leave a disparaging comment in the code, and me to post it on TheDailyWTF (that's still how I think of this website, and what my coffeecup still says).

Re: Not the Most Thought Out Enumeration

2007-07-14 06:27 • by sergio (unregistered)
145591 in reply to 145419
inglorion:
In the Bourne shell, an exit code of 0 indicates success, and any other indicates an error.

As well as a lot of functions in libc. Just have to get used to it.

Re: Not the Most Thought Out Enumeration

2007-07-14 07:19 • by DrawFire (unregistered)
145593 in reply to 145411
Or just subtract from 1
« PrevPage 1 | Page 2Next »

Add Comment