Comment On get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

"As part of my new role for a software development firm," writes David Mayer, "I was assigned to sift through some code looking for bugs in the dictionary and spellchecking system. That's how I came across a function called get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function." [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:33 • by Zunetang (unregistered)
tl;dr - dan rather just pist frost.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:33 • by DaveK
Passed as a perimeter? Sounds kinda edgy to me.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:36 • by MikeN (unregistered)
My favorite part is that it's version 15.1.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:37 • by 3rd Ferguson (unregistered)
I thought we frowned on using student code as WTFs.

//CAPTCHA: "inhibeo" - the spell that causes Hermione to get nervous and put her robe back on

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:38 • by M (unregistered)
This function just skirts the issue...

Captcha: feugiat - feugiataboutit

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:39 • by KattMan
Honestly it's a language parser, should be easy to do all numbers with little more code.

Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

Yeah this function is a serious WTF, even in its name, sounds like the forgot to name it and just put the comment as the name.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:40 • by Anon (unregistered)
I love how schizophrenic this is. On the one hand you've got a variable named "WORD_CONVERTED_FROM_A_NUMBER_PASSED_THROUGH_A_PERIMETER", but on the other hand you have "HX_373".

It's like a epic battle between overly long descriptive variable names and short, completely cryptic variable names, fighting for the soul of this function.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:40 • by Julia
I can't wait for the future version that handles up to 10^8...

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:40 • by DaveK
379176 in reply to 379170
MikeN:
My favorite part is that it's version 15.1.
And "enterprise edition", no less!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:41 • by configurator (unregistered)
379177 in reply to 379173
KattMan:
Honestly it's a language parser, should be easy to do all numbers with little more code.

Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

Yeah this function is a serious WTF, even in its name, sounds like the forgot to name it and just put the comment as the name.


"Eightteen" for 18 would be better than "four" for 5, I guess... (see "bugs fixed")

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:43 • by Anon (unregistered)
'Establish p_mode to define correct perimeter
If p_mode = "" Then
p_mode.Replace("", "No perimeter was passed through")
Else
p_mode = p_mode
End If

If p_mode = "No perimeter was passed through" Then
p_mode = ""
Else
If p_mode = "" Then
p_mode.Replace("", "No perimeter was passed through")
Else
p_mode = p_mode
End If
End If


I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:44 • by GoodtimesSnuggler (unregistered)
I like the bugs fixed

"'Shortened name of the function due to errors on polling the function"

THIS IS THE SHORTER NAME?!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:47 • by Coyne
Enterprisey. Very enterprisey. Also shtupid.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:48 • by NickS (unregistered)
At one of my previous jobs they hired a new guy not because he was qualified in any way for the job, but solely on the basis that he used to be a Russian rocket scientist during the Cold War.

Instead of doing the things required of his job, he spent 8 hours a day making calendars in MS Paint with various decorations for each month, printing them out, and handing them to everyone in the department. If he made a change to one month, he reprinted everything out again for everyone and went around swapping out the old calendars for the new ones.

He was fired in two weeks. For some reason, seeing this code reminded me of him. Good intentions, poor execution, completely irrelevant to the task at hand.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:50 • by ubersoldat
379182 in reply to 379180

Patched this function so that mode offers expert perimeter settings for advanced programmers


Yeah right!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:53 • by Bruce W (unregistered)
One of my elementary school teachers told me if I am going to spell a word wrong at least keep the same spelling throughout what I am writing. Glad to see someone else took that lesson to heart. (yes, yes "perimeter" is a real word...)

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:55 • by Quirkafleeg (unregistered)
I like the fact that the first bug fixer could spell "three" but thought "eleevn" was a perfectly acceptable number.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:56 • by TGV
THE BUG FIXES! THE BUG FIXES!! OMG, THEY DO NOTHING!!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:56 • by Rafael Giusti (unregistered)
379186 in reply to 379169
> Passed as a perimeter? Sounds kinda edgy to me.

TUDUM TSS!!!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:58 • by Decius (unregistered)
379187 in reply to 379178
Anon:
'Establish p_mode to define correct perimeter
If p_mode = "" Then
p_mode.Replace("", "No perimeter was passed through")
Else
p_mode = p_mode
End If

If p_mode = "No perimeter was passed through" Then
p_mode = ""
Else
If p_mode = "" Then
p_mode.Replace("", "No perimeter was passed through")
Else
p_mode = p_mode
End If
End If


I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.


Not quite nothing- if you pass "no perimeter ...", it changes to an empty string.

Granted, it doesn't do anything remotely useful, but that's not the same thing as a NOP.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:59 • by Michal (unregistered)
379188 in reply to 379169
He meant definitely "parameter" when writing "perimeter". Then it starts making sense.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 09:59 • by C-Octothorpe
379189 in reply to 379174
Anon:
I love how schizophrenic this is. On the one hand you've got a variable named "WORD_CONVERTED_FROM_A_NUMBER_PASSED_THROUGH_A_PERIMETER", but on the other hand you have "HX_373".

It's like a epic battle between overly long descriptive variable names and short, completely cryptic variable names, fighting for the soul of this function.
*golf clap*

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:02 • by Bleat (unregistered)
'API call removed due to high demand


1) How much was this used that this was ever in 'high demand'
2) What kind of API call would this even use? What's more, would it actually have been useful?

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:02 • by Weps

"... Please try again"


Hahaha

Management material

2012-04-16 10:09 • by Doug (unregistered)
Time for this programmer to enter the ranks of management and spend the rest of his/her career saying how "we used to do it."

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:10 • by Steve The Cynic
If you ask me, whoever wrote it was just taking the piss. It would be worth the submitter's while, I think, to search for calls to this.

In code that's reachable from somewhere reachable, if you get my drift...

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:11 • by KattMan
379195 in reply to 379192
Ok Code challenge!

Challenge A: write one that can handle conversion of numerics to text without range failures (we can limit at somewhere around the millions? billions?) in the fewest lines possible.

Challenge B: write one that still gives the answer but in the most convoluted way.

Challenge C: By far the easiest, do one or the other challenges but in a way that we can't tell what you were going for.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:14 • by Jaunticed (unregistered)
I'm banking on this being just a joke. Evidence?

'Shortened name of the function due to errors on polling the function

Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:15 • by PiisAWheeL
379197 in reply to 379187
Decius:
Anon:
'Establish p_mode to define correct perimeter
If p_mode = "" Then
p_mode.Replace("", "No perimeter was passed through")
Else
p_mode = p_mode
End If

If p_mode = "No perimeter was passed through" Then
p_mode = ""
Else
If p_mode = "" Then
p_mode.Replace("", "No perimeter was passed through")
Else
p_mode = p_mode
End If
End If


I can't even begin to understand the thought process here. 15 lines that do absolutely nothing. It simplifies to p_mode = p_mode which is a NOP.


Not quite nothing- if you pass "no perimeter ...", it changes to an empty string.

Granted, it doesn't do anything remotely useful, but that's not the same thing as a NOP.
My thoughts exactly. But it also made my eyes bleed.

'Shortened name of the function due to errors on polling the function
Shortened it from what?!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:16 • by Prosthetic Lips
379198 in reply to 379188
Michal:
He meant definitely "parameter" when writing "perimeter". Then it starts making sense.


True, but since this function was for a dictionary and spell checker, that makes it even more ironic!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:18 • by _rnd (unregistered)
get_comment_from_a_number_and_post_comment_to_function_and_submit_to_website_tdwtf()

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:19 • by Spider Flyer (unregistered)
Wow...

...How old is this code? Because I saw _working_ code that would do this in a '79 or '80 copy of 'Creative Computing'.

Also, you can find working code online if you search for a one of the 'large' number suffixes plus the name of your favorite computer language.

For example, while searching for 'septillion c#', I found: http://www.vb-helper.com/howto_net_number_to_words2.html

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:22 • by the beholder (unregistered)
379201 in reply to 379170
MikeN:
My favorite part is that it's version 15.1.
I bet that "bug fixes" section is gonna be quite long by the time he puts 10^8 in the range.

Whoever wrote this code should be thrown out the window... of a orbital station.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:25 • by KattMan
379202 in reply to 379201
the beholder:
MikeN:
My favorite part is that it's version 15.1.
I bet that "bug fixes" section is gonna be quite long by the time he puts 10^8 in the range.

Whoever wrote this code should be thrown out the window... of a orbital station.


In a degrading orbit or with exiting force?

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:25 • by geoffrey, MCP, PMP (unregistered)
379203 in reply to 379196
Jaunticed:
I'm banking on this being just a joke. Evidence?

'Shortened name of the function due to errors on polling the function

Considering that the EXAMPLE USAGE shows what we can guess was the previous function name, and how the new name is needlessly verbose... yeah.


One of Visual Basic's many useful features is an Eval function, which executes any text string you hand to it as code. The original author is probably using Eval, and has discovered a limitation on length for the argument.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:31 • by vt_mruhlin (unregistered)
'Sometimes a 'four' would be outputted when '5' was passed through the perimeter

Can we all take a moment to imagine just how bad the original version of this must have been if that particular problem only reproed sometimes?

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:34 • by KattMan
379205 in reply to 379204
vt_mruhlin:
'Sometimes a 'four' would be outputted when '5' was passed through the perimeter

Can we all take a moment to imagine just how bad the original version of this must have been if that particular problem only reproed sometimes?


Was this a problem, perhaps when 5 breeched rthe perimeter one was actually removed by security. This could be expected behaviour.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:35 • by da Doctah
379206 in reply to 379173
KattMan:
Honestly it's a language parser, should be easy to do all numbers with little more code.

Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

Did you learn that when you were threeteen, or wait until you turned fiveteen?

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:38 • by PedanticCurmudgeon
379207 in reply to 379194
Steve The Cynic:
If you ask me, whoever wrote it was just taking the piss. It would be worth the submitter's while, I think, to search for calls to this.

In code that's reachable from somewhere reachable, if you get my drift...
I was thinking the same thing when I saw the response.write in the middle of the function.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:41 • by KattMan
379208 in reply to 379206
da Doctah:
KattMan:
Honestly it's a language parser, should be easy to do all numbers with little more code.

Go 1-9, then 10-12, then 13-19 becomes easy (nine) + (teen)
After that everything else is easy 21, 31 are (twenty) + (one) or (thirty) + (one).

Did you learn that when you were threeteen, or wait until you turned fiveteen?


I learned it back when I was eleventeen!

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:45 • by ObiWayneKenobi
Looks like something Nagesh would write; isn't that the type of Hinglish that he writes in?

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:47 • by Anketam
379210 in reply to 379179
GoodtimesSnuggler:
I like the bugs fixed

"'Shortened name of the function due to errors on polling the function"

THIS IS THE SHORTER NAME?!
I had the identical reaction.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:50 • by Anonymous (unregistered)
379211 in reply to 379208
Really? I didn't learn it until eleventyone.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 10:53 • by toth
I like that he replaces the empty string with that useless string...but only when the parameter is the empty string.

Because assigning literals to parameters is for suckers.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 11:02 • by Tim (unregistered)
obviously a hoax, but a hilarious one :-)

the 'bug fixed' is the best part

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 11:20 • by Kasper (unregistered)
379214 in reply to 379177
configurator:
better than "four" for 5, I guess... (see "bugs fixed")
Given the look of the code it is not surprising that such a bug could have slipped in. What scares me is that it only happened sometimes.

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 11:28 • by big picture thinker (unregistered)
p_comment = "Guys take it easy on him. He obviously never dealt with perimeters before and was just experimenting with this advanced technology. I'd like to see any of you implement a function that uses perimeters!"
If p_comment = "" Then
p_comment = ""
Else
p_comment = p_comment
End If

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 11:44 • by mschaad (unregistered)
I just appreciated the fact that the English output is still wrong.

[GrammarNazi]
13,387,281 rendered as words should read
"thirteen million three hundred eighty-seven thousand two hundred eighty-one". Note that the word "and" is not in there at all, and tens are properly hyphenated. :-)
[/GrammarNazi]

Also, to render numbers correctly as words (with the hyphens and everything) is a harder trick than you might think.
Thankfully, standard English style dictates that you pretty much never spell out any numbers above nine.

So where would you need a library like this, unless your app writes checks?

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 11:56 • by itsmo (unregistered)
Seriously, did no one else notice "forteen"

Re: get_words_from_a_number_which_is_passed_as_a_perimeter_into_this_function

2012-04-16 12:08 • by dogmatic (unregistered)
Firing's too good for this clown. I do believe a hanging's in order.
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Add Comment