Comment On Quite Contrary

Mike writes, "Oh, the things that I find in our codebase." [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: Quite Contrary

2010-02-10 09:01 • by Yalpe Nismou (unregistered)
So Mary is a boy's name where ?

Re: Quite Contrary

2010-02-10 09:02 • by Mr Mary (unregistered)
TRWTF here is the gender param me thinks

Re: Quite Contrary

2010-02-10 09:03 • by Josh (unregistered)
Chosen by fair sample from population. Guaranteed to be random.

Re: Quite Contrary

2010-02-10 09:04 • by jspenguin
http://xkcd.com/221/


int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}

Re: Quite Contrary

2010-02-10 09:07 • by Bernard Mergendeiler (unregistered)
Looks OK to me. One of my coworkers once wrote a random function which always returned 6. He argued that 6 was as likely as any other number.

Re: Quite Contrary

2010-02-10 09:14 • by pg4 (unregistered)
And then along comes......

Re: Quite Contrary

2010-02-10 09:20 • by ds111 (unregistered)
What do the "few places" do with it when they've called it? I suspect a few more WTFs lurking there.

Re: Quite Contrary

2010-02-10 09:22 • by toth
Yet another falls victim to the "random" == "arbitrary" error.

Re: Quite Contrary

2010-02-10 09:22 • by Thg (unregistered)
298639 in reply to 298629
Yalpe Nismou:
So Mary is a boy's name where ?


nowhere ... otherwise you wouldn't be insulting the guy's manhood when you used it as an insult.

e.g., "Stop whining about the code, .. Mary."

Re: Quite Contrary

2010-02-10 09:25 • by Ed (unregistered)
But we all know the getReallyRandom name will return . . . 'Dave'

Re: Quite Contrary

2010-02-10 09:27 • by Mel
298641 in reply to 298629
Well, if there can be a boy named "Sue"...

Re: Quite Contrary

2010-02-10 09:35 • by Anonymous Coward (unregistered)
298643 in reply to 298641
Mel:
Well, if there can be a boy named "Sue"...


...then we can meet our ellipsis quota for the day... or can we...?

Re: Quite Contrary

2010-02-10 09:38 • by Cujo (unregistered)
I think it was to keep 'Paula' or 'Kevin' from popping up.

Re: Quite Contrary

2010-02-10 09:41 • by powerlord
No the real WTF here is using PHP for OO. ;)

Re: Quite Contrary

2010-02-10 09:46 • by Ian (unregistered)
298647 in reply to 298629
Yalpe Nismou:
So Mary is a boy's name where ?


Could be short for "Marion". Not common but there are some men with that name. Not up to par with "Kelly", "Chris", "Terry", "Courtney", "Pat", "Lynn" or "Beverly".

Re: Quite Contrary

2010-02-10 09:46 • by TarquinWJ
TRWTF is that just under half of the places where it is called use "true" as the param, just under half use "false" as the param, and the remainder use FILE_NOT_FOUND. There, that should dust it off nicely.

Re: Quite Contrary

2010-02-10 09:47 • by Kempeth (unregistered)
You need to look for seedRandomNameGenerator(string name). It will change the name and recompile the code.

Re: Quite Contrary

2010-02-10 09:48 • by Steve the Cynic (unregistered)
C'mon guys, is nobody (aside from me, that is) going to mention Marion Morrison in the quest for confused names?

And never mind the problems my father had owing to the USian tendency to assume that Robin is a girl's name...

Re: Quite Contrary

2010-02-10 09:51 • by Callin
I'm guessing the coder initially put in a bogus return value just so it would return a string as expected, but forgot to go back later and actually make it do what was it was supposed to.

Re: Quite Contrary

2010-02-10 09:51 • by Steve the Cynic (unregistered)
298652 in reply to 298648
TarquinWJ:
TRWTF is that just under half of the places where it is called use "true" as the param, just under half use "false" as the param, and the remainder use FILE_NOT_FOUND. There, that should dust it off nicely.

gender == true presumably would apply to the entire population, even those who are confused about what the gender actually is. We all *have* a gender, right?

(Well, pedantically speaking, no, we don't. Gender is a concept in grammar, so "Gender Studies" is a narrow subfield of linguistics.)

Re: Quite Contrary

2010-02-10 09:52 • by Someone too lazy to login and at work (unregistered)
298653 in reply to 298629
Yalpe Nismou:
So Mary is a boy's name where ?


In theory, anywhere you want. Erich Remarque's middle name was Maria.

Re: Quite Contrary

2010-02-10 09:52 • by Justsomedude (unregistered)
298654 in reply to 298633
Josh:
Chosen by fair dice roll from sample population. Guaranteed to be random.


ftfy? or was that intentional?

Re: Quite Contrary

2010-02-10 09:56 • by F. G. (unregistered)
You can never really know...

Re: Quite Contrary

2010-02-10 10:03 • by () (unregistered)
Actually, it makes a lot of sense. Someone wrote a mock for this function to test other functionalities and they accidentally forgot to implement the proper code. The only WTF I see here is not adding a "// TODO: implement this" and something like "#ifndef debug error 'the implementation is not finished'"
Captcha: nulla (are we still posting the captchas?)

Re: Quite Contrary

2010-02-10 10:04 • by Mel
298657 in reply to 298643
Anonymous Coward:
Mel:
Well, if there can be a boy named "Sue"...


...then we can meet our ellipsis quota for the day... or can we...?

What? It's a perfectly valid use, according to http://en.wikipedia.org/wiki/Ellipsis. "An ellipsis can also be used to indicate a pause in speech, an unfinished thought, or, at the end of a sentence, a trailing off into silence (aposiopesis) (apostrophe and elipsis mixed)."

On the other hand, I did fail at quoting.

Re: Quite Contrary

2010-02-10 10:10 • by JakeyC (unregistered)
298658 in reply to 298653
Someone too lazy to login and at work:
Yalpe Nismou:
So Mary is a boy's name where ?


In theory, anywhere you want. Erich Remarque's middle name was Maria.


And one step closer, Charles Widor's was Marie...

Re: Quite Contrary

2010-02-10 10:12 • by SCB (unregistered)
298659 in reply to 298652
Steve the Cynic:
TarquinWJ:
TRWTF is that just under half of the places where it is called use "true" as the param, just under half use "false" as the param, and the remainder use FILE_NOT_FOUND. There, that should dust it off nicely.

gender == true presumably would apply to the entire population, even those who are confused about what the gender actually is. We all *have* a gender, right?

(Well, pedantically speaking, no, we don't. Gender is a concept in grammar, so "Gender Studies" is a narrow subfield of linguistics.)

As the saying goes:
Words have gender, people have sex.

Re: Quite Contrary

2010-02-10 10:14 • by mernen
Actually, the "really random" method is called "real_getRandomName".

Re: Quite Contrary

2010-02-10 10:19 • by Glen (unregistered)
I guess there must be something about Mary.

Re: Quite Contrary

2010-02-10 10:26 • by A Nonny Mouse
298663 in reply to 298656
we never were.

Re: Quite Contrary

2010-02-10 10:27 • by juca (unregistered)
In embedded systems where you normally don't even have a file system, is very common to use Mary as a random name.

Re: Quite Contrary

2010-02-10 10:27 • by Sika (unregistered)
Yet another thread on yet another forum with the same story, linking same xkcd and Dilbert...

Re: Quite Contrary

2010-02-10 10:29 • by Cypholus (unregistered)
Not quite like kevin
captcha secundum... On a second thought maybe mary is better

Re: Quite Contrary

2010-02-10 10:29 • by NSCoder
It should return "Slartybartfast". Now that's a random name.

Re: Quite Contrary

2010-02-10 10:35 • by Kiss me I'm Polish
It all depends on initial condidions.
What is the universe of names that the function is supposed to choose from? Biblical names? Female names? English names? Employee database?
Then - why would anyone need a random name? My first guess, to use in an example (credit card mockup) or in English tests ("Mary ________ to school").
On second guess, it could be used in advertisement. Say, a user is logged in - the ad shows him a credit card with his name on it. But what to do when the user is not logged in? Let's show him some random name - in this case Mary.
It would be more fun though to have Heywood Jablome.

Re: Quite Contrary

2010-02-10 10:51 • by dacrocky (unregistered)
you can just rename it to getTheRandomName then it will be true. =)

Re: Quite Contrary

2010-02-10 10:53 • by thosrtanner
298671 in reply to 298629
Yalpe Nismou:
So Mary is a boy's name where ?


It's not an uncommon boy's name in Eire (Republic of Ireland)

Re: Quite Contrary

2010-02-10 10:54 • by Steve A (unregistered)
Obligatory inane pop-culture reference:

There's something about Mary...

Re: Quite Contrary

2010-02-10 11:00 • by Zylon
298673 in reply to 298660
mernen:
Actually, the "really random" method is called "real_getRandomName".

Nah, do it the Oracle way--

GET_RANDOM_NAME2

Re: Quite Contrary

2010-02-10 11:11 • by skinnytie (unregistered)
TRWTF is that submitter's source control system did not provide him a changelog.

I mean, he must be using a source control system, right?

Re: Quite Contrary

2010-02-10 11:26 • by Swedish tard (unregistered)
298675 in reply to 298656
():
Actually, it makes a lot of sense. Someone wrote a mock for this function to test other functionalities and they accidentally forgot to implement the proper code. The only WTF I see here is not adding a "// TODO: implement this" and something like "#ifndef debug error 'the implementation is not finished'"
Captcha: nulla (are we still posting the captchas?)


Oooh, Im SO going to start putting that into our codebase wherever I find a //TODO: or //FIXME: ... Might even modify our commit scripts to do it. :)

Re: Quite Contrary

2010-02-10 11:30 • by Maurits
> Mary is a boy's name where?

Middle-Earth.

Re: Quite Contrary

2010-02-10 11:34 • by Montoya (unregistered)
The coder clearly forgot to randomize the possibilities. Here is the correct way to do this:

public static function getRandomName($gender)
{
$names = array('Mary');
shuffle($names);
return $names[0];
}

Re: Quite Contrary

2010-02-10 11:36 • by EvanED
298680 in reply to 298668
NSCoder:
It should return "Slartybartfast". Now that's a random name.

How big of a geek am I for immediately recognizing that the correct spelling of that is Slartibartfast?

Re: Quite Contrary

2010-02-10 11:44 • by K (unregistered)
298681 in reply to 298637
ds111:
What do the "few places" do with it when they've called it? I suspect a few more WTFs lurking there.


It's a helper method for the random number generator.

int randomNumber = getRandomName().ToCharArray().Count

Re: Quite Contrary

2010-02-10 11:47 • by Danny V (unregistered)
Kevin would never have wrote something like that. He would have created a database of all possible names and returned a truly random result every time.

Sure do miss that guy...

Re: Quite Contrary

2010-02-10 11:51 • by Lorne Kates
Allow me to refactor that for you:


public static function getWhatTheWindCries($gender)
{
return 'Mary';
}

Re: Quite Contrary

2010-02-10 11:54 • by Mason Wheeler
In Spanish, Italian, and probably a bunch of related languages, "Mario" is the masculine version of "Maria" (Mary), and is a fairly common male name.

Re: Quite Contrary

2010-02-10 12:02 • by Helix
298686 in reply to 298634
jspenguin:
http://xkcd.com/221/


int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}


XKCD references are banned on the daily wtf - we have logged your IP address and will be running random DDoS

Re: Quite Contrary

2010-02-10 12:06 • by Aaron
298687 in reply to 298634
jspenguin:
http://xkcd.com/221/


int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}

Honestly, do you people just sit around all day waiting for opportunities to post the same two xkcd references?
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment